您的位置:首页 > 编程语言 > C语言/C++

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

2015-04-15 15:54 281 查看
#include <stdio.h>
#include <tchar.h>

char* UnicodeToAnsi( const wchar_t* szStr )
{
int nLen = WideCharToMultiByte( CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL );
if (nLen == 0)
{
return NULL;
}
char* pResult = new char[nLen];
WideCharToMultiByte( CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL );
return pResult;
}

void  main(){

TCHAR msg[100];
swprintf_s(msg, L"sjlkjdkld");
char *str=UnicodeToAnsi(msg);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: