CString str;
str=_T("87654321");
TCHAR chArray[256] = {0};
TCHAR strTmp[16] = {0};
TCHAR *strBuffer = str.GetBuffer();
int index = 0;
int iPrev = 0;
int lenth = 0;
while (*(strBuffer + index) != _T('\0'))
{
_itot(*(strBuffer + index), strTmp, 10);
lenth = _tcslen(strTmp);
_tcscpy(chArray+iPrev, strTmp);
iPrev += lenth;
ZeroMemory(strTmp, sizeof(strTmp) / sizeof(TCHAR));
chArray[iPrev] = _T('\n');
iPrev++;
index++;
}
::MessageBox(NULL, chArray, _T("ASCII"), MB_OK);
由于在ASCII,字符1~9在代表数字49~58,所以只要减去‘0’他所对应的ASCII的值就可以了
int i=0;
while(*str!='\0')
{
cout<
i++;
}
简单
有 right(s,n)从右取n个字符的
还有mid(s,i,n)s中第i个位置去n个字符的
这就够了
Asc(c) 转换成那个ASCII值的
这个转换确实有点麻烦,下面给出我经常用的转换方法:
#include
#pragma
comment(lib,
"comsuppw.lib")
cstring
strtest;
char
*psztest;
_bstr_t
bstr;
strtest
=
"cstring
to
char*";
bstr
=
strtest;
psztest
=
bstr;
这样char*与wchar_t*相互转换就非常方便了