C++ 中TCHAR字符串数组转化为Char类型数组

 1 #include <stdio.h> 
 2 #include <tchar.h>  
 3 
 4 char* UnicodeToAnsi( const wchar_t* szStr ) 
 5 { 
 6  int nLen = WideCharToMultiByte( CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL ); 
 7  if (nLen == 0) 
 8  { 
 9     return NULL; 
10  } 
11  char* pResult = new char[nLen]; 
12  WideCharToMultiByte( CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL ); 
13  return pResult; 
14  } 
15 
16 void  main(){
17 
18     TCHAR msg[100]; 
19     swprintf_s(msg, L"sjlkjdkld"); 
20     char *str=UnicodeToAnsi(msg);
21 
22 }
原文地址:https://www.cnblogs.com/kire/p/4428821.html