1. CString字符串类型中提取以特定字符分隔的子串
使用库函数AfxExtractSubString
CString str = “sssdf sfds jieuri lj122 98098”;
CString strGet(_T(""));
CStringArry strArry;
while (AfxExtractSubString(strGet, str, i++, _T(' ')))
{
strArry.Add(strGet);
}
int d = strArry.GetSize();
for (int j=0; j<d; j++)
{
MessageBox(strArry.GetAt(j));
}
CString str = “sssdf sfds jieuri lj122 98098”;
CString strGet(_T(""));
CStringArry strArry;
while (AfxExtractSubString(strGet, str, i++, _T(' ')))
{
strArry.Add(strGet);
}
int d = strArry.GetSize();
for (int j=0; j<d; j++)
{
MessageBox(strArry.GetAt(j));
}
2. 字符串转为int ,用库函数:
string s = "123";
int num = atoi(s.c_str());
3. int转为字符串:
int i = 234;
char str[10];
itoa(i,str,10);
cout<<str<<endl;
4.十六进制输出
char * ptr = (char *)&m;
int n = sizeof(m);
for (char *p = ptr; p != ptr + n; ++p) {
printf("%02x", *p);
}
printf("\n");