**1.**TASK.JSON :
"-fexec-charset=GBK", // 设置执行字符集为 GBK
"-finput-charset=UTF-8", // 输入字符集为 UTF-8
2.
int main()
{
SetConsoleOutputCP(6501); //必须加这一行。
}
cpp
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile with GCC",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"group": {
"kind": "build",
"isDefault": false
},
"problemMatcher": [
"$gcc"
]
},
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "E:\\msys64\\ucrt64\\bin\\gcc.exe",
"args": [
"-fexec-charset=GBK", // 设置执行字符集为 GBK
"-finput-charset=UTF-8", // 输入字符集为 UTF-8
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
]
}