Before you start
Set up VS Code to run C++, you can keep reading here or follow the official guide here: https://code.visualstudio.com/docs/languages/cpp#_example-install-mingwx64
First install the C/C++ extension
Then install a c++ compiler, I’m going to use MinGW-x64, head to this page and download the installer: https://www.msys2.org After it’s done installing click finish and a terminal should open up.
You can use these commands to install everything that is necessary:
$ pacman -S mingw-w64-ucrt-x86_64-gcc
$ pacman -S - needed base-devel mingw-w64-x86_64-toolchain
The last step is to add the MinGW compiler to your path
- Look for the the \mingw64\bin folder and copy the folder path
- Go to your environment variables -> system environment
Test it
Create a .cpp file and copy the following code
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
}
Now execute these commands
g++ Filename.cpp -o customname
./customname.exe
Now you can start learning :)