第一次在vscode上运行c文件 这样了怎么办 求解惑

img

可能是没有安装和配置gcc编译器以及vscode的相关插件,参考一下这里http://c.biancheng.net/view/8114.html。

vscode编译运行c++需要配置launch.json和task.json文件。

launch.json:
{
  "name": "Gcc Debug",//调试界面中显示的名字
  "type": "cppdbg",
  "preLaunchTask": "gccdebug",//这个很重要,在运行前进行编译的命令,对应task配置
  "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
    }
  ]
}
 
task.json:
{
    "label": "gccdebug", //launch.json中要调用的名字。
    "type": "shell",
    "command": "gcc.exe", //Gcc.exe路径需要配置到PATH里
    "args": [
        "${file}",
        "-g", //debug参数
        "-fexec-charset=gbk""-o",
        "${fileDirname}/${fileBasenameNoExtension}.exe",
    ]
}

如果你是想写c或者c++,最推荐的还是上vs,2015,17,19版本都行,下个社区版本就够了,其他版本的的功能目前你估计也用不到,vscode适合老手会自己折腾的,diy程度比较高