16,473
社区成员
发帖
与我相关
我的任务
分享
CString strInput="0A 0B 0C 0D ";
CString str;
char Input[100];
memset(Input,0,100);
int nStart=0;
int nFind=0;
int nIndex=0;
strInput.MakeUpper();
while((nFind=strInput.Find(" ",nStart))>=0)
{
str = strInput.Mid(nStart,nFind-nStart);
for(int i=0; i<str.GetLength(); i++)
{
if(str[i]>='0'&&str[i]<='9')
Input[nIndex] = Input[nIndex]*16 + str[i]-'0';
else if(str[i]>='A'&&str[i]<='F')
Input[nIndex] = Input[nIndex]*16 + str[i]-'A'+10;
}
nStart=nFind+1;
nIndex++;
}
if(nStart<(strInput.GetLength()-1))
{
str = strInput.Mid(nStart,strInput.GetLength()-nStart);
for(int i=0; i<str.GetLength(); i++)
{
if(str[i]>='0'&&str[i]<='9')
Input[nIndex] = Input[nIndex]*16 + str[i]-'0';
else if(str[i]>='A'&&str[i]<='F')
Input[nIndex] = Input[nIndex]*16 + str[i]-'A'+10;
}
}
CString strText(_T("0A 0B 0C 0D 0E 0F"));
#define MAX_COUNT 256
TCHAR buf[MAX_COUNT] = {0};
int curPos = 0;
LPCTSTR pszToken = _T(" ");
CString strTmp(_T(""));
int nIndex = 0;
while(_T("") != (strTmp = strText.Tokenize(pszToken, curPos)))
{
if(nIndex >= MAX_COUNT)
break;
buf[nIndex++] = (TCHAR)_tcstoul(strTmp, NULL, 16);
}