vscode快速配置c++
本文为快速配置教程,无技术含量,可快速运行c++文件。
1.新建工程,如test
2. 在test中新建.vscode文件夹,注意有点.
3.在.vscode中新建launch.json和tasks.json文件
4.分别添加如下内容
4.1 launch,json(注意有路径的修改)
{ "version": "0.2.0", "configurations": [ { "name": "C/C++", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "D:mingw64/bin/gdb.exe", //改为自己的路径 "preLaunchTask": "g++", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], }, ] }
4.2 tasks.json
{ "version": "2.0.0", "command": "g++", "args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.exe" ], "problemMatcher": { "owner": "cpp", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } }, "group": { "kind": "build", "isDefault": true } }
5. 验证是否成功
#include <stdio.h> using namespace std; int main(){ printf("Hello World !"); }