代码如下,运行后如输入有英文有中文(如输入abc一二三)输出是abc���,英文部分输出正常(abc),中文部分输出不正常(���),全是乱码,输入全是英文,输出正常,输入全是中文,输出全是乱码,求帮助!!!
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string input(string Input){
string Output;
cout<<Input<<"\n";
cin>>Output;
return Output;
}
int main(){
string Input="???";
string Output=input(Input);
printf_s(Output.c_str());
return 0;
}
VScold1.94.2
gcc.exe (Rev3, Built by MSYS2 project) 14.1.0
g++.exe (Rev3, Built by MSYS2 project) 14.1.0
GNU gdb (GDB) 15.1
win11
C17
C++17
c_cpp_properties.json如下
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/msys64/ucrt64/bin/gcc.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
launch.json如下
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
//"program": "${fileDirname}:\\program.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
//"miDebuggerPath": "D:\\msys64\\mingw64\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
settings.json如下
{
"files.associations": {
"iostream": "cpp",
"string": "cpp",
"*.tcc": "cpp"
}
}
tasks.json如下
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "D:\\msys64\\ucrt64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
//"*.c",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
//"${fileDirname}\\program.exe"
//"${workspaceFolder}\\${workspaceRootFolderName}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}