VSCode的安裝就不講了,可以參考這個(http://www.cnblogs.com/dunitian/p/6661644.html)
寫一個簡單的C,然后F5運行,根據提示來配置文件
刪掉前面的內容
運行發現還是不行,Ctrl+Shift+B,輸入Task
選擇Others
把command和args配置一下,${file}代表當前打開文件
Ctrl+Shift+B生成一下
F5運行調試
官方文檔:https://code.visualstudio.com/docs/languages/cpp
參考:
https://code.visualstudio.com/docs/editor/tasks
https://code.visualstudio.com/docs/editor/debugging
附錄:
2018.3.19更新
Ctrl+Shift+B編譯下,添加tasks文件
tasks.json 最新配置:
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "c++", "type": "shell", "command": "g++", "args": [ "-g", "${file}" ], "group": { "kind": "build", "isDefault": true } } ] }F5運行一下,添加launch文件
launch.json最新配置
{ // 使用 IntelliSense 了解相關屬性。 // 懸停以查看現有屬性的描述。 // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.out", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }