- char szValue[] = "ABCDEFabcdef";
- CString szReturn;
- for(int i = 0;i < sizeof(szValue);++i)
- {
- szReturn.AppendFormat(_T("%x"),szValue[i]);
- }
- cout<<szReturn.GetLength()<<endl;
- // 逆运算
- int nLength = szReturn.GetLength();
- char p[50];
- string sz;
- for (int i = 0;i < nLength/2; ++i)
- {
- CString a = szReturn.Mid(i*2,2);
- string b= CT2A(a);
- int j = strtol(b.c_str(),NULL,16);//
- sz.append<int>(1,/*atoi(b.c_str())*/j);
- }
- strcpy(p,sz.c_str());
- //该片段来自于http://www.codesnippet.cn/detail/1809201410468.html
来源: http://www.codesnippet.cn/detail/1809201410468.html