码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-04-15 16:48:21      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

 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 }

 

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

标签:

原文地址:http://www.cnblogs.com/kire/p/4428821.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!