VSCode+各种语言环境配置
一、C++
新建C++示例代码
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg {"Hello", "C++", "World", "from", "VS Code!"};
for (const string& word : msg)
{
cout << word << " ";
}
cout << endl;
}
点击右侧设置,选择“C/C++: g++.exe build and debug active file”即可,运行编译得到.exe文件和输出
二、C
可查看vscode官方配置链接:https://code.visualstudio.com/docs/cpp/config-mingw
下载c语言编译器:https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z/download
解压后将bin文件夹加入系统化境变量,cmd中输入gcc -v有gcc信息即是配置成功
#include <stdio.h>
#include <stdio.h>
#include <string.h>
int main()
{
char *msg ="Hello C World from VS Code!";
printf("%s",msg);
return 0;
}
点击右侧设置,选择“C/C++: gcc.exe build and debug active file”即可,运行编译得到.exe文件和输出
若要调试,则将task和launch中的program都设置成${fileDirname}\${fileBasenameNoExtension}
三、Python
msg = "Hello Python World from VS Code!"
print(msg)
因为Python环境已经添加到系统路径了,所以只需要在运行时选择Python文件即可