小一 发表于 2022-4-2 15:27:11

C++ TCHAR转char*最新写法源码

感觉自己不够努力,只能努力才有结果!

char* TCHAR2char(const TCHAR* STR)

{

        //返回字符串的长度

        int size = WideCharToMultiByte(CP_ACP, 0, STR, -1, NULL, 0, NULL, FALSE);

        //申请一个多字节的字符串变量

        char* str = new char;

        //将STR转成str

        WideCharToMultiByte(CP_ACP, 0, STR, -1, str, size, NULL, FALSE);

        return str;

}

页: [1]
查看完整版本: C++ TCHAR转char*最新写法源码