无法在vscode中调试

问题描述 投票:0回答:1

[我正在尝试在vscode中调试C代码,当我单击debug时,集成终端,调试控制台中显示了一些内容,但是我希望输出的内容未打印在任何地方,例如printf()的输出未显示在任何地方,我正在尝试使用scanf()接受用户输入,但也不起作用。

c debugging visual-studio-code output vscode-debugger
1个回答
0
投票

显然,我只是通过尝试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"
        }
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.