C++ tchar转char,string

C++ tchar转char,string

tchar2char

void tchar2char(tchar* input,char* output){
    int length = WideCharToMultiByte(CP_ACP, 0, input, -1, NULL, 0, NULL, NULL);
	WideCharToMultiByte(CP_ACP, 0, input, -1, output, length, NULL, NULL);
}

tchar2string

void tchar2string(tchar* input,string& output){
   int length = WideCharToMultiByte(CP_ACP, 0, szDir, -1, NULL, 0, NULL, NULL);
   char ch[] = "";
   WideCharToMultiByte(CP_ACP, 0, szDir, -1, ch, length, NULL, NULL);
   output = string(ch);
}

 

你可能感兴趣的:(MFC,C++)