求字符的ASCII值与其对应的字符串之间的双向转换(BYTE<==>STRING)的程序 百分大放送!! 想要实现的功能描述如下:"AB"(该二个字符的ASCII值分别对应 41 42 ) <==> "4142"("AB"字符串的ASCII值的String 形式)请问如何实现二者间的相互转换,敬请指教!最好是程序,谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 "AB"=>"4142" use %x format 字符付给整型char ch = 'A';int a = ch;char buffer[20];itoa( a, buffer, 10 );反过来转换:每取两位用int a = atoi("41");char ch = (char)a; CString str1="AB";CString str,str2="";int i=0;for(i=0;i<str1.GetLength();i++){str.Format("%02X ",str1[i]);str2=str2+str;} 刚才贴得有问题:是针对10禁制ASCII值的 1.CString str1("AB"),str2, sT ;int nLen = str1.GetLength() ;for( int i = 0 ; i < nLen ; ++ i ){sT.Format( "%d", str1[i] ) ;str2 += sT ;}///////////////////////////2.CString str1( "4142" ), str2, sT ;int nLen = str1.GetLength() / 2 ;for( int i = 0 ; i < nLen ; ++ i ) {sT = str1.Mid( i, 2 ) ;str2 += (TCHAR)atoi(sT) ;} 1:CString str1="AB";CString str,str2="";int i=0;for(i=0;i<str1.GetLength();i++){str.Format("%02X ",str1[i]);str2=str2+str;}2: char c; CString str1= "41 42" , str2, str3 =""; str1+=" "; while (str1!="") { str2=str1.Left(str1.Find(" ")); str1=str1.Mid(str1.Find(" ")+1); sscanf(str2,"%02X",&c); str3=str3+c; } CString str = "AB";CString str1;str1.Format("%02X%02X", str[0], str[1]);str1 = "4142";DWORD data = strtoul((LPCTSTR)str1, NULL, 16);char *p = (char*)&data;*(p+2) = *p;p++;str = p; 2个窗口间通信,是否需要加锁 为什么要把-1转换成无符号整数 多线程提问 怎么打开PDF文件? 我想把double类型的数组写入一个txt文件中,该用什么函数,如何操作? 求助: 怎样用代理上教育网的ftp? 求教:如何用VC使用Dao访问Access2k bind error 这句ADO的Recordset有什幺问题呢? 关于图像列表DRAW的问题 成功用socket的到了web网页的内容,如何只得到<html>和</html>的内容 “参数不足,期待是1”这个关于数据库操作的异常是什么意思?
char ch = 'A';
int a = ch;
char buffer[20];itoa( a, buffer, 10 );反过来转换:
每取两位用
int a = atoi("41");
char ch = (char)a;
CString str,str2="";
int i=0;
for(i=0;i<str1.GetLength();i++)
{
str.Format("%02X ",str1[i]);
str2=str2+str;
}
是针对10禁制ASCII值的
CString str1("AB"),str2, sT ;
int nLen = str1.GetLength() ;
for( int i = 0 ; i < nLen ; ++ i )
{
sT.Format( "%d", str1[i] ) ;
str2 += sT ;
}
///////////////////////////
2.
CString str1( "4142" ), str2, sT ;
int nLen = str1.GetLength() / 2 ;
for( int i = 0 ; i < nLen ; ++ i )
{
sT = str1.Mid( i, 2 ) ;
str2 += (TCHAR)atoi(sT) ;
}
CString str,str2="";
int i=0;
for(i=0;i<str1.GetLength();i++)
{
str.Format("%02X ",str1[i]);
str2=str2+str;
}2:
char c;
CString str1= "41 42" , str2, str3 ="";
str1+=" ";
while (str1!="")
{
str2=str1.Left(str1.Find(" "));
str1=str1.Mid(str1.Find(" ")+1);
sscanf(str2,"%02X",&c);
str3=str3+c;
}
CString str1;
str1.Format("%02X%02X", str[0], str[1]);str1 = "4142";
DWORD data = strtoul((LPCTSTR)str1, NULL, 16);
char *p = (char*)&data;
*(p+2) = *p;
p++;
str = p;