gpt4 book ai didi

c++ - 如何在 Dev C++ 上显示带有中文字母的行?

转载 作者:行者123 更新时间:2023-12-02 10:31:14 25 4
gpt4 key购买 nike

我想要的是显示用户输入的带有中文字母的行。虽然程序 DevC++。

这是我的代码:

#define UNICODE
#include <iostream>
#include <string>
using namespace std;
extern wostream wcout;
int main(int argc, char** argv) {
std::wstring kanji = L"?";
//std::wchar_t stop = L"0";
std::wcout << L"\n\nWelcome to the Chinese letter program\n";
std::wcout << L"The program will ask you for one Chinese letter\n";
std::wcout << L"Then press enter, and a message will display.\n";
std::wcout << L"Once you are done,you can enter another Chinese letter\n";
std::wcout << L"To exit just close the Ubuntu's terminal'\n\n";
for(int x = 0; x < 80; x++){
std::wcout << L"Give me one Chinese letter...";
wcin >> kanji;
std::wcout << L"The Chinese letter is \"" << kanji << "\".\n\n";
}
return 0;
}

对我来说重要的是“汉字是“(汉字)”。线。当我按照程序说的做时,我得到“中文字母是“?”。所以问题是 DevC++ 没有正确显示中文字母,即使我使用 wcin 和 wcout 的东西。

注意我在 Ubuntu 上通过 wine 使用 DevC++。

最佳答案

你的控制台支持中文编码吗?看看这个帖子
How to print a Chinese character?

关于c++ - 如何在 Dev C++ 上显示带有中文字母的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62164673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com