1、在unicode字符集下
#include <iostream>
#include <atlstr.h>
using namespace std;
void main()
{
CString str = "ABC";
string ss = "SSS";
const char *p = ss.c_str();
char *p2 = "bbbb";
wchar_t *p3 = L"cccc";
string st = p2;
str.Format(_T("%s"), p3);
//printf("%S\n", str);
}
说明:当转换的是字符串时,Format的第二个参数必须是wchar_t(宽字符)
2、在多字符集下
#include <iostream>
#include <atlstr.h>
using namespace std;
void main()
{
CString str = "ABC";
string ss = "SSS";
const char *p = ss.c_str();
char *p2 = "bbbb";
wchar_t *p3 = L"cccc";
string st = p2;
str.Format(_T("%s"), p2);
//printf("%S\n", str);
}
说明:当转换的是字符串时,Format的第二个参数必须是char