wchar_t转为char*

Posted 柳鲲鹏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wchar_t转为char*相关的知识,希望对你有一定的参考价值。

具体代码:

static char* add_arg_to_array(const wchar_t* arg)
{
    int iSize = WideCharToMultiByte(CP_ACP, 0, arg, -1, NULL, 0, NULL, NULL);
    char* chdata = (char*)malloc(iSize*sizeof(char));
    WideCharToMultiByte(CP_ACP, 0, arg, -1, chdata, iSize, NULL, NULL);

    return chdata;
}

以上是关于wchar_t转为char*的主要内容,如果未能解决你的问题,请参考以下文章