字符转换 将 CString str=_T("3131313032");转换成 str=_T("12202"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 str.Format(_T("%d/n"),12202); int index = -1;while(index = str.Find('3') >= 0){ str.Delete(index);} 我上面说的问题只是给大家具个例子, _T("313233") 都是ASCII码的16进制,他们在内存里存储的形式是 33 00,31 00,33 00 ,32 00 我想让他们改成内存的存储形式为 31 00,32 00,33 00。转换过来就是_T("123"); #include <iostream>int _tmain(int argc, _TCHAR* argv[]){ char _s[100]="300031003200\0"; char str[4]; char a; for(int j=0;j<100&&_s[j]!='\0';j=j+4) { for(int k=0;k<4;k++) { str[k]=_s[j+k]; } a=atoi(str)/100-30+'0'; std::cout<<a; } std::cin>>a; return 0;} 什么意思?是不是 31 31 31 30 32 是16进制ASCII码对应的字符?但是应是 11102 才对。 ASCII码转字符串 很多方法 我上面说的问题只是给大家具个例子, _T("313233") 都是ASCII码的16进制,他们在内存里存储的形式是 33 00,31 00,33 00 ,32 00 33 00,33 00 我想让他们改成内存的存储形式为 31 00,32 00,33 00。转换过来就是_T("123");是所有的字符串型16进制ASCII码转换 CString str=_T("3131313032"); CString dst; TCHAR buff[2]; buff[1]=0; int c=0; int n=str.GetLength(); for (int i=0;i<n;i+=2) { swscanf(str.Mid(i,2),_T("%x"),&c); swprintf(buff,_T("%c"),c); dst+=buff; } CString str=_T("3131313032");str.Replace(_T("3"),_T("")); CString strHex = _T("3131313032");CString strDst = _T("");CString str = _T("");int c = 0;for(int i=0; i<strHex.GetLength(); i+=2){ c = _tcstoul(strHex.Mid(i,2), NULL, 16); str.Fotmat(_T("%c"), c); strDst += str;}MessageBox(strDst); // 11102 谢谢各位。如果在字符串里存在汉字的编码怎么办。例如, CString tmp=_T("313233C8CB"); 其中C8CB到一起为“人”; 看来我的汉语不过关哦,呵呵 CString tmp =_T("313233c8cb")里面的31,32,33,和c8cb都是AScII编码的16进制,在ASCII表里 ‘31’对应的数据是‘1’‘人’对应的编码为‘c8cb’。我想把tmp转换成 tmpresult=_T("123人"); 逐个_wtoi,转换为TCHAR后,向一个CString追加 为什么在状态条上无法显示时间? 高分寻求高手帮助 关于安全登录邮箱或ftp的问题 VC反编译工具 在VS2005里,怎么获取EDIT的内容? 请问如何才能做到每次只显示窗口的一部分内容? 三个帖子共200多分,关于dx9 sdk的问题,请高手帮忙,前面两个帖子问题都没有解决 怎样得到winXP的API列表和详细解释(中英文皆可)。 大虾救命!!!如何向调制解调器发送at命令? 参与者有分! CRecordSet 只读集 不能写数据,提示错误为“只读集” 校园网安装一个Socket服务器,该在什么位置?
str.Format(_T("%d/n"),12202);
while(index = str.Find('3') >= 0)
{
str.Delete(index);
}
{
char _s[100]="300031003200\0";
char str[4];
char a;
for(int j=0;j<100&&_s[j]!='\0';j=j+4)
{
for(int k=0;k<4;k++)
{
str[k]=_s[j+k];
}
a=atoi(str)/100-30+'0';
std::cout<<a;
}
std::cin>>a;
return 0;
}
CString dst;
TCHAR buff[2];
buff[1]=0;
int c=0;
int n=str.GetLength();
for (int i=0;i<n;i+=2)
{
swscanf(str.Mid(i,2),_T("%x"),&c);
swprintf(buff,_T("%c"),c);
dst+=buff;
}
str.Replace(_T("3"),_T(""));
CString strDst = _T("");
CString str = _T("");
int c = 0;
for(int i=0; i<strHex.GetLength(); i+=2)
{
c = _tcstoul(strHex.Mid(i,2), NULL, 16);
str.Fotmat(_T("%c"), c);
strDst += str;
}MessageBox(strDst); // 11102
逐个_wtoi,转换为TCHAR后,向一个CString追加