#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
cin >> a; // 假设输入: 中文
cout << a << endl;
}
在vscode运行结果是 空的 和 一些符号 有时还是字母pp
但是在cmd运行是正常的
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
cin >> a; // 假设输入: 中文
cout << a << endl;
}
在vscode运行结果是 空的 和 一些符号 有时还是字母pp
但是在cmd运行是正常的
编译编码和终端编码不一致, 一般都是windows下会出的问题.
统一一下试试
#include <iostream>
#include <string>
using namespace std;
int main()
{
#ifdef _WIN64
system("chcp 65001");
#endif
string a;
cin >> a; // 假设输入: 中文
cout << a << endl;
}