VSCODE 调试C程序时 打印中文

**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": "调试器生成的任务。"

        }

    ]

}
相关推荐
读书札记202218 小时前
visual studio 调试技巧总结
ide·visual studio
袋子(PJ)20 小时前
2026年常见的配置文件格式——为什么程序员永远在折腾缩进和括号?—— 常见配置文件进化史(md文档很详细)
编辑器
hacker70721 小时前
Visual Studio安装教程(C#开发版)
ide·c#·visual studio
千码君20161 天前
flutter: 分享一下基于trae cn 构建的过程
java·vscode·flutter·kotlin·trae
我才是一卓1 天前
2026 Python 入门教程,结合 vscode 和 miniforge/miniconda
开发语言·vscode·python
XD7429716361 天前
科技早报晚报|2026年5月1日:本地优先文档、安卓离线 IDE 与双击即用密码库,今天最值得跟进的 3 个机会
android·ide·科技·科技新闻·开发者工具·本地优先
謓泽1 天前
【Trae IDE】核心功能详解与使用教程
ide·ai·trea
lzl20401 天前
VSCode中Codex CLI登录卡在‘Sign in with ChatGPT‘屏幕
ide·vscode·chatgpt·codex
SkyXZ~1 天前
Mac上使用VScode优雅开发STM32
vscode·stm32·macos
xskukuku1 天前
VSCode中的Codex插件如何调用第三方API
vscode·ai·codex