char数组和TCHAR相互转换

接口函数实现:
TCHAR 转char
void TcharToChar(const TCHAR * tchar, char * _char)
{
int iLength;
//获取字节长度
iLength = WideCharToMultiByte(CP_ACP, 0, tchar, -1, NULL, 0, NULL, NULL);
//将tchar值赋给_char
WideCharToMultiByte(CP_ACP, 0, tchar, -1, _char, iLength, NULL, NULL);
}
char转TCHAR
void CharToTchar(const char * _char, TCHAR * tchar)
{
int iLength;
//获取字节长度
iLength = MultiByteToWideChar(CP_ACP, 0, _char, -1, NULL, 0, NULL, NULL);
//将tchar值赋给_char
MultiByteToWideChar(CP_ACP, 0,_char, -1, tchar , iLength, NULL, NULL);
}

你可能感兴趣的:(指尖的味道_c++)