参考文章
VSCODE C语言终端输出中文乱码编码设置
问题描述
VS Code默认文件编码时UTF-8,这对大多数情况是没有问题的,却偏偏对C/C++有问题。如果以UTF-8编码保存C/C++代码,那么只能输出英文,另外使用不同的编辑器打开改代码时,中文注释也可能会乱码。
解决方法
文件 ⇒ 首选项 ⇒ 设置,点击右侧图标,打开setting.json

在setting.json
中添加两项
"[cpp]": {
"files.encoding": "gbk"
},
"[c]": {
"files.encoding": "gbk"
}

以后新建.c .cpp文件时,将默认为GBK编码,中文不会乱码了。