How to setup Visual Studio Code for c/c++ languages

a year ago

In this article we are going to learn how to setup complete c and c++ development environment in Visual studio code, this is the easy and efficient process compared to the process which is given in Visual studio code official website.

Why should i use Visual Studio code?

  • Visual code has one of the best GUI( Graphical user Interface) and make your code clean and easy to read.
  • Large number of extensions are present in Visual code for faster and versatile coding experience.
  • Auto-completion of code and keyword which is very great feature for beginners.
  • Small in size and does not very demanding in term of hardware.
  • Great debugging features to help user in inspecting the code.

PREREQUISITE

  • You should have the latest version of MinGW( it is a native window port of the GNU Compiler collection (GCC) ) install on your computer system, if not you can head towards the following link and can download the software according to your system operating system and architecture.

Download MinGW.

  • Download Visual Studio Code software from official site. Note:- Download the community version, it is free of cost.
  • Connect to your internet connection for installing MinGW using the setup.

Steps to install MinGW and add environment variable path on your system:-

  1. open the .exe file and click on install button by selecting the directory for installation, it will download some files and then redirect you into new page.
  2. In this page check the box which says mingw32-gcc-g++.bin.
  3. Then click on Installation located at top-left menu and then click on apply changes.
  4. It will download and install the files, it might take several minutes depending on your internet connection.
  5. Now you are done with mingw installation ,lets add the environment variable path.
  6. Go to the directory where you install the mingw then go to the bin folder and copy the path location by clicking on the upper tab next to search bar.
  7. Now head to this location System info->advance system settings-> environment variables->click on path present in 2nd tab and click edit-> click new and copy the path location of mingw bin folder-> click ok.
  8. Now you are pretty much done, just check that the path is added successfully or not by opening cmd and typing "path". If you can see the mingw bin path, you are good to go.

STEPS TO SETUP VISUAL CODE FOR C/C++:-

  1. Go to Extension tab and download c/c++ Intellisense extension and install the extension on your device.
  2. After than search for code runner in extension search bar and also install it ( code runner is a tool to run all code snippets and code files for multiple languages like c++,c,python,java,PHP,javascript,ruby and many more.)
  3. Now you can write the "hello world" program in c/c++ language to check that all things are working as expected.
  4. You can also change the themes and looks of the editor easily in settings menu.

If you followed the all the steps correctly there should not be any problem in setting Visual code for c/c++, if not you can comment down the problems and error. Thank you and enjoy the fast and smart coding experience.

Frequently Asked Questions

Yes the community version of Visual studio code is free of cost.

Just download the HTML,CSS and javascript extension and you are good to go.