声明
不喜勿喷
安装(以下以Win10为例)
首先打开官网并下载VS Code 安装程序(Win7系统用最后一个支持Win7的版本)
双击及下载,其他的可以不改
这个可以根据需要勾选
环境变量
右键dev-c++,打开文件所在位置
将MinGW64移到C盘(可以不移,但是需要改动路径)
复制路径
)
win+r键打开运行,输入sysdm.cpl
回车确定,点击高级,再点击环境变量
找到Path,并点击编辑
点击新建,把路径粘贴进去
配置 VS Code
找到左边的5个图标,并点击最后一个,搜索chinese,下载并改变语言
搜索c++,并安装这两个
然后新建一个文件夹用于放置文件
附录-代码(放到.vscode中)
第一个
文件名:launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) C and C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"internalConsoleOptions": "neverOpen",
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
],
"preLaunchTask": "Compile"
},
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
第二个
文件名:settings.json
{
"C_Cpp.errorSquiggles": "disabled",
"C_Cpp.default.compilerPath": "C:\\MinGW64\\bin\\gcc.exe",
"files.associations": {
"iostream": "cpp",
"suiji": "c",
"random": "cpp",
"ostream": "cpp"
}
}
第三个
文件名:tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile",
"command": "C:\\MinGW64\\bin\\g++.exe",
"args": [
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe",
"-g",
"-std=c++11",
"-m64",
"-Wall",
"-static-libgcc",
"-fexec-charset=GBK",
"-D__USE_MINGW_ANSI_STDIO"
],
"type": "process",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": "$gcc"
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
]
}