配置中文
Ctrl+shift+x 输入lan,找到中文安装即可
配置C++环境
网上教程https://www.cnblogs.com/bpf-1024/p/11597000.html
新建空文件夹Code
打开VScode --> 打开文件夹 --> 选择刚刚创建的文件夹Code
新建main.cpp文件
#include<stdio.h>
#include<stdlib.h>
int main(){
printf("Hello World!");
return 0;
}
进入调试界面添加配置环境,选择 C++(GDB/LLDB),再选择 g++.exe,之后会自动生成
launch.json 配置文件
编辑 launch.json 配置文件
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true, //弹出终端
"MIMode": "gdb",
"miDebuggerPath": "E:\\environment\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++.exe Task"
}
]
}
返回.cpp文件,按F5进行调试,会弹出找不到任务"task g++",选择
"配置任务",会自动生成 tasks.json 文件
编辑 tasks.json 文件
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++.exe Task",
"command": "E:\\environment\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "E:\\environment\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
【注】: launch.json 文件中 "preLaunchTask" 的值 必须与 tasks.json 文件中
"label"的值一致。值的设置任意