聘我网

新概念招聘3.0

linux下打印unicode失效?

vote up0vote downstar
#include <stdio.h>
#include <wchar.h>

int main(int argc, char *argv[])
{
    wprintf(L"test %s %s %s\n",L"one",L"two",L"three");
    return 0;
}

上面这段,MSVC执行正常:

test one two three

但在linuxgcc编译执行却不对:

test o t t

且编译还会抛一个警告:

警告:隐式声明函数 ‘wprintf’

如何解决这个问题?

 

1 个答复

vote up0vote downcheck

应该使用%ls:

printf(L"test %ls %ls %ls\n",L"one",L"two",L"three");

至于警告,需要加上-std=c99或者-std=gnu99.

链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.