首页 > 解决方案 > 在 Visual Studio Code 中使用 C++ 进行调试时如何读取输入而不丢失编码?

问题描述

我想调试一个上面有 std::cin 的代码。

如果我把 launch.json '"externalConsole": false' 放在上面,我什么也写不出来(因为没有控制台可以处理它)。

但是,如果我输入“externalConsole”:true,我的 shell 参数将被忽略。

我只使用 IntelliSense。

启动.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - Criar e depurar o arquivo ativo",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Habilitar a reformatação automática para gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe arquivo de build ativo"
        }
    ]
}

设置.json:

{
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe",
    "terminal.integrated.shellArgs.windows": [
        "/k",
        "chcp 65001"
    ],
    "workbench.colorTheme": "Visual Studio Dark - C++",
}

我需要使用 '"terminal.integrated.shellArgs.windows": ["/k", "chcp 65001"]' 来使用我的编码系统。

有没有办法解决这个问题?

标签: c++windowsvisual-studio-code

解决方案


推荐阅读