【问题标题】:Unable to debug in vscodevscode无法调试
【发布时间】:2020-05-18 07:30:41
【问题描述】:

我正在尝试在 vscode 中调试 C 代码,当我点击调试时,在集成终端、调试控制台中显示了一些内容,但我想要的输出没有打印在任何地方,例如 printf() 的输出没有显示,我是尝试使用 scanf() 获取用户输入,但它也不起作用。

【问题讨论】:

  • 你能分享任何图片来演示吗?
  • 我碰巧解决了它并发布了答案。谢谢你..

标签: c debugging visual-studio-code output vscode-debugger


【解决方案1】:

显然我碰巧通过在launch.json 文件中尝试不同的东西来解决我自己的问题。 我设置了属性"externalConsole": true,其值默认设置为false。 现在打开一个外部命令提示符窗口并在那里打印输出以及用户输入工作。 以下是我的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": "gcc.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc.exe build active file"
        }
    ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 2019-12-16
    • 2021-08-10
    • 2021-07-22
    相关资源
    最近更新 更多