Learn How To Run C/C++ Codes In VS Code: Step By Step Guide :-

ai
Introduction: This article is step by step guide of running c/c++ codes in your Computer with easiest method. So without wasting time Lets go...

Step 1: Download MinGW


Go to the website of Mingw and download Mingw from it according to your Operating System.

Link: https://sourceforge.net/projects/mingw/
ai
Click on Download and download it.

Step 2: Install MinGW


Go where you downloaded the minGW and open it.

ai
Click on Install.

ai
Click on Continue and minGW will start installing.

After the installation this windows will get open.
ai
Click on these packages and mark them for installation.
ai
Click on Installation and then click on Apply Changes.
ai
Click on Apply and the packages will start getting downloaded that will take upto 5 minutes so let it to get downloaded and finally after complete downloaded, close it.


Step 3: Set MinGW Path


Go where you downloaded MinGW and open that folder and then open bin folder in it And copy it's Path. ai

Go to your settings and search system properties/environment variable and then navigate to EnvironmentVariables>Path of System Variables>Edit>New and then paste the path you copied and OK all the windows.
ai

Now open VS Code, and then open Terminal in your c/c++ file And use following commands for running c/c++ codes.

• For C - gcc ./filename.c -o exefilename.exe - type this in the terminal and press enter, this command will create an exe file with the given name after -o i.e "exefilename".
ai

Now type ./exefilename.exe in terminal and press Enter. This will show the output of your C file in the terminal.
ai

• For C++ - Just replace the gcc with g++ and all process same.