1.将string转化为char*
string s("你好");
char *nihao=s.data();
char *nihao=s.c_str();
2.将string转化为TCHAR[]
string res("你好");
TCHAR wc[MAX_PATH];
#ifdef UNICODE
_stprintf_s(wc, MAX_PATH, _T("%S"), res.c_str());//%S宽字符
#else
_stprintf_s(wc, MAX_PATH, _T("%s"), res.c_str());//%s单字符
或者
TCHAR wc[256];
MultiByteToWideChar(CP_ACP,0,(LPCSTR)res.c_str(),-1,wc, 256);
3.将 TCHAR *转化为string
std::string TCHAR2STRING(TCHAR *STR)
{
int iLen = WideCharToMultiByte(CP_ACP, 0,STR, -1, NULL, 0, NULL, NULL);
char* chRtn =new char[iLen*sizeof(char)];
WideCharToMultiByte(CP_ACP, 0, STR, -1, chRtn, iLen, NULL, NULL);
std::string str(chRtn);
return str;
}