Chinaunix
标题:
输出中文诡异问题
[打印本页]
作者:
danshiming
时间:
2016-02-18 09:50
标题:
输出中文诡异问题
各位大侠:
本小虾今天在linux下尝试编写了一个很简单的程序,如下:
#include<iostream>
#include<string>
#include<stdio.h>
using std::wstring;
using std::wcout;
using std::string;
using std::cout;
int main(int argc, char**argv)
{
wcout << "春天";
cout << "lichunlin";
printf("danshiming\n");
int i;
std::cin >> i;
return 1;
}
发现只要是输出中文的都无法输出,且中文输出语句后面的英文也无法输出,即上例中:只要有wcout << "春天";代码存在,
“春天”不能输出,且其后的 cout << "lichunlin";printf("danshiming\n");都无法输出,那我要输出的中文咋办?期盼大侠帮忙解释下啊
我的linux系统是CentOS 6.5
作者:
happy_fish100
时间:
2016-02-18 10:24
显示终端的字符集没有设置好?
作者:
bruceteen
时间:
2016-02-18 11:18
试试执行
std::locale loc = std::locale::global( std::locale(std::locale(),"",std::locale::ctype) );
之类的设置代码
作者:
snowman1101
时间:
2016-02-19 12:01
wcout 是需要 const wchar_t* 的
而你的 "春天" 是 char*
你试试看 L"春天"
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2