VS code配置c/c++
链接: VS code官方配置链接
官方的配置方法还是很好用的,网上配置MinGW的方法还是比较麻烦的,按照文档敲敲命令行就好了。
出现问题
gdb没有下载成功,再重复执行一次pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
,按enter就好了,或,选择mingw-w64-ucrt-x86_64-gdb
项下载。
所以一定要检查是否 MinGW-w64 工具是否正确安装且可用 ,在命令行依次输入以下
gcc --version
g++ --version
gdb --version
编译程序
这里是官方页面提供的程序。
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string& word : msg)
{
cout << word << " ";
}
cout << endl;
}
注意是cpp程序,使用g++默认编译。这里看着其他的博客不小心使用了gcc,一直报错。
可以看看gcc与g++的区别。
运行成功。
问题:VsCode输出中文乱码
发现中文输出乱码
VsCode输出中文乱码