如何在Windows中的VS Code上键入集成终端?

凯文·C·黄瓜

在Linux中,我可以键入集成终端,没问题。我可以输入用户输入,它将输出。在Windows上,我不能这样做。输出显示在调试控制台中,我无法在该控制台或集成终端中键入内容。

在图中,我在C ++中运行时没有调试,当我要求输入时,它挂在那里并且没有输出。我看过CodeRunner,但我不愿意使用它。

运行时终端的图片。

编辑

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "g++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}
安森

默认情况下,C ++程序输出到的调试控制台支持用户输入。这意味着C ++程序不会读取在调试控制台中输入的内容。

要解决此问题,请文件中将行更改"externalConsole": false"externalConsole": truelaunch.json以便C ++程序可以在外部控制台中运行。这样,您可以输入用户输入并被正在调试的C ++程序解释。

launch.json现在应该看起来像:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "g++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,    // <-- Changed to "true" in here
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

在此处阅读更多内容:在Visual Studio Code中使用C ++进行调试时,如何读取输入?

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在 VS Code 的集成终端中设置下拉视图?

如何从Visual Studio Code集成终端在Windows上使用Bash?

如何在 macOS Big Sur 上修复 VS Code 集成终端时断时续的问题?

如何在VS Code集成终端中运行Metro Bundler,而不是运行新窗口?

VS Code中集成终端中的Bash终端颜色

如何在Visual Studio Code或VSCode中更改集成终端

如何在Visual Studio Code中从集成终端打开文件?

如何在 Windows 上更新 VS Code?

VS Code集成终端的颜色主题

使用VS Code从集成终端打开文件

终止集成终端后,VS Code冻结

Mac Catalina上Visual Studio Code的集成终端中的“ zsh:找不到命令:ng”

VS Code终端如何在Windows(WSL)的Ubuntu(Ubuntu)上使用Bash?

如何在 Windows 10 VS Code 或 PyCharm 终端中查看我的环境变量?

如何使用CMDR作为vs code默认集成终端

如何在VS Code中添加多个终端?

如何在 VS Code 中从终端运行 python 代码?

如何使分支名称出现在VS Code集成终端中?

如何检查Shell脚本/ Vim是否在VS Code集成终端中运行?

如何在Windows上从CLI卸载VS Code

VS Code快捷方式可集中集成终端

集成终端设置VS Code和iTerm返回zsh

集成终端停止在 Visual Studio Code 中显示文本

如何在 Windows 中为 VS Code 手动安装 python 包?

如何在VS Code中创建“终端配置宏”?轻松打开和拆分多个终端

VS Code中的Python:我可以在集成终端中运行单元吗?

如何在Windows中记录终端会话?

如何在VS Code中更改光标?

如何在VS Code中关闭TextDocument?