Luc_c 2022-09-05 07:47 采纳率: 66.7%
浏览 830

如何用vscode调试程序并查看变量的值

刚刚开始使用vscode不知道如何调试,点击了右上侧按钮后出现了以下情况:

img

img

img

  • 写回答

1条回答 默认 最新

  • 浪客 2022-09-05 07:57
    关注
    点那个打开launch.json后,写入下面launch.json内容,在.vscode文件夹新建一个task.json文件,复制下面内容。
    task.json
    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "g++debug",
                "type": "shell",
                "command": "gcc.exe",
                "args": [
                    "${file}",
                    "-g",
                    "-o",
                    "${fileDirname}/${fileBasenameNoExtension}.exe"
                ]
            }
        ]
    }
    
    
    launch.json
    
    {
      // 使用 IntelliSense 了解相关属性。
      // 悬停以查看现有属性的描述。
      // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
        {
          "name": "G++ Debug",
          "type": "cppdbg",
          "preLaunchTask": "g++debug",
          "request": "launch",
          "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
          "args": [],
          "stopAtEntry": false,
          "cwd": "${fileDirname}",
          "environment": [],
          "externalConsole": true,
          "MIMode": "gdb",
          "miDebuggerPath": "gdb.exe",
          "setupCommands": [
            {
              "description": "为 gdb 启用整齐打印",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true
            }
          ]
        }
      ]
    }
    

    展开全部

    评论
    编辑
    预览

    报告相同问题?

    手机看
    程序员都在用的中文IT技术交流社区

    程序员都在用的中文IT技术交流社区

    专业的中文 IT 技术社区,与千万技术人共成长

    专业的中文 IT 技术社区,与千万技术人共成长

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    客服 返回
    顶部