注册 登录
编程论坛 C++教室

双字节型代码问题

q5095995 发布于 2011-08-17 19:22, 289 次点击
#include <iostream>
#include <locale>
using namespace std;
int main()
{
    setlocale(LC_ALL,"chs");
wchar_t wt[]=L"中";
wcout<<wt;
    return 0;
}

输出以后内容为空,不知道哪里的问题.
1 回复
#2
xg56992011-08-17 19:31
此程序在vc 2005下不会有任何输出,因为在vc 2005中,wcout输出流对象必须配合imbue函数来设置本地化,修改下就好了
#include <iostream>
#include <locale>
using namespace std;
int main()
{
    wcout.imbue(locale("chs"));
wchar_t wt[]=L"中";
wcout<<wt;
    return 0;
}

1