tchar和char 互相转换

 

 

//将TCHAR转为char   
//*tchar是TCHAR类型指针,*_char是char类型指针   
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);   
}  

  

CharToTchar (const char * _char, TCHAR * tchar)  
{  
    int iLength ;  
  
    iLength = MultiByteToWideChar (CP_ACP, 0, _char, strlen (_char) + 1, NULL, 0) ;  
    MultiByteToWideChar (CP_ACP, 0, _char, strlen (_char) + 1, tchar, iLength) ;  
} 

  

 

 

 

some from:https://blog.csdn.net/ahjxly/article/details/8494217

posted @ 2021-03-31 19:39  HappyCoder_1  阅读(985)  评论(0编辑  收藏  举报