int htoi(const char* psz)
{
ASSERT(psz);
size_t nlen = ::strlen(psz);
int result = 0;
for(size_t i = 0; i < nlen; i++)
{
int digit = ctoi(*psz++);
result += int(digit*::pow(16, nlen - 1 - i));
}
return result;
}
这个函数可以直接完成你的要求。
CString sp("51d3fc34");
CString showbox;
DWORD show;
sscanf(sp,"%x",&show);
showbox.Format("%08x",show);
AfxMessageBox(showbox);