The Visual Studio C++ compiler requires several environment variables to be set in order to successfully compile your code. If you are using a Windows machine with the Visual Studio C++ compiler, there are two ways you can ensure the environment is applied.
You only need to do one of the following:
Run the C/C++: Set Visual Studio Developer Environment command
Start VS Code from the Developer Command Prompt for VS
Close the current instance of VS Code.
Open the Developer Command Prompt for VS by typing developer in the Windows Start menu then select the Developer Command Prompt for VS.
Type code into the command prompt and hit enter. This should relaunch VS Code in the same workspace and take you back to this walkthrough.