How to Set Up Visual Studio for C++ Programming Window 11

Today, we’ll demonstrate how to install Visual Studio Code and get it ready for C and C++ programming in windows 11.

One of the most popular programming languages in use today is C/C++, and one of the most popular IDEs for C/C++ development is Microsoft Visual Studio.

Programming in C and C++ is best done with the popular development tool Visual Studio Code. It is an open-source tool with features that are comparable to those of Visual Studio.

Microsoft created Visual Studio Code, which is essentially a simple source code editor. Windows 11, macOS, Linux, and other operating systems all support it.

This blog post will discuss how to pair Microsoft’s new lightweight and quick editor, Code, with Visual Studio.

How to Set Up Visual Studio Code for C and C++

 How to download Visual Studio Code in Windows 11

Following are the steps to install Visual Studio Code.-

  • Installing Visual Studio on your Windows 11 operating system will now begin. You must first download it from this page.

Download the Visual Studio code

  • Simply double-click the downloaded file to install Visual Studio Code after you’ve finished downloading it.
  • After agreeing to the licensing agreement and choosing your installation directory, click next. You can also let it run on auto-pilot. after which select next.
  • Check each option in this stage as shown in the screenshot below (important). Click next after that, and then choose Install.
  • Click Finish once the Vs code installation is finished.

How to add the system path to the MinGW bin directory in Windows 11

The MinGW 64 compiler must now be downloaded and installed. If you are unsure how to do so, see this post: How to Install and set up MinGW-w64 C/C++ Compiler.

The MinGW bin directory will now be added to the system path.

After completing these steps, add the directory containing MinGW plus bin. You must include C:mingwbin in your path if, for instance, MinGW is installed in C:.

  • On the desktop, right-click My Computer and choose Properties.
  • In the System Properties window, click the Advanced tab.
  • In the Advanced section, click the Environment Variables button.
  • Finally, click the Edit button after selecting the Path variable in the Systems Variable section of the Environment Variables window.
  • The paths you want the machine to be able to access should be substituted for the path lines. Each directory is separated by a semicolon, as shown below.

C:\Program Files;C:\Winnt;C:\Winnt\System32;c:\mingw\bin

Now we will download some helpful extensions to Visual Studio Code to make your c or c++ code run faster.

Installing extensions in visual studio code in Windows 11

We will install these two extensions

  1. C/C++
  2. Code Runner

To get these extensions, simply open Visual Studio Code and click the button below.

  • The extension will then be installed after you type in “c/++” and press the install button.
  • Our following extension will be code runner.
  • To obtain this extension, perform the same search for “code runner” as before, choose “install,” and then wait for the process to be completed.
  • Once both extensions have been installed, restart Visual Studio Code.


If you need to get input from the user after downloading the code runner extension, you can’t do it through this output tab because it’s read-only. We will therefore need to find a solution to this problem.

Observe the directions provided to resolve this error.

  • Click the file that has at least the top corner visible to get started.
  • Now select settings from the preferences menu.
  • Extensions should be chosen in the drop-down menu. You can click on the run code configuration if you scroll down now.
  • Continue to scroll down to check the run in the terminal.
  • Press Ctrl+S to save and leave the settings after that.

Running your first program in Visual Studio code

After setting up Visual Studio Code for C and C++ programming, we must run a simple C program to ensure that GCC and Visual Studio Code are both functional.

Open any folder on your computer to do this. Right-click once more, and then choose Visual Studio Code from the menu that appears.

To run your first program, create a file called demo.cc.

And Write a simple Hello World c or c++ program as 

// Your First C++ Program

#include <iostream>

int main() {

    std::cout << “Hello World!”;

    return 0;

}

NOW press Ctrl+s and then click the run button to save it.

Congratulations on successfully setting up Visual Studio Code for C and C++ programming languages if your program runs.

Conclusion

Microsoft’s free and open-source Visual Studio Code code editor has extensions that make it an excellent tool for programming.
Debugging, task execution, and version control are supported by the streamlined code editor Visual Studio Code. It aims to give developers only the tools they require for a quick cycle of code-build-debugging and leaves more complex workflows to IDEs with more features, like Visual Studio IDE.

This blog demonstrated how to install some extensions for C and C++ programming as well as how to set up Visual Studio Code for C and C++ programming.

Leave a Comment

Your email address will not be published. Required fields are marked *

Tesla Provides a Demo to an Agency Investigating Self-Driving Claims The final module has docked with China’s Tiangong space station. Catastrophic collision! A dangerous asteroid has been discovered. NASA expects Elon Musk’s SpaceX to launch its first Starship this year NASA Will Launch A “Flashlight” To Look For Drinking Water On The Moon