How to Setup VSCode for C/C++ and Run First Program (2024 Update) - Visual Studio Code Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's see how we can set up CN C++ in Visual Studio code and write our first C program first of all we need to install a compiler for C and C++ so for the sake of this tutorial we will be installing MW first go to this URL I'll have this in the description below you can copy it from there or you can just click it and this page will be opening and once we have this website open just click on this download button so the setup is now downloaded now just click on open file or double click from your download folder it will open and this is the installer click on install and leave these as it is just click on continue and now it is downloading the required files once this is complete click on continue and this installation manager will open now on the list we need to install this base and click on markone installtion and we need this G g++ again click on this and click mark for installation so once we have these two open we can run C and C++ so other things are for other languages as you can see this is for Ada this is for Fortran and so on and after you have selected these two just click on installation and click on apply changes and the installation will start after you click on apply so as you can see the installation for C and C++ compiler has started so as you can see all the changes were applied successfully now you can close this dialog so click on close and you can close this to and you can close your browser too now go to your C drive here and you will see this MW folder is being created here go inside this and there's a bin here go inside this and copy this copy this path so that we can run C and C++ from our terminal and we can compile C code or C++ code from terminal now press your Windows key and search for invite ironment variables this you can type full thing here variables and click on this click on environment variables and here click on path and click on edit and here at the bottom paste what we have just copied click okay click okay again click okay and now we can open Terminal or command prompt and let's check if GCC or mean mean GW is successfully installed so you can type g++ double Das version and as you can see MW version 6.3.0 is now installed and now you can compile CN C++ code so after the compiler is installed Press Your Windows key and open vs code click on this or the shortcut is control shift X and now you can search for C and C++ c/ C++ as you can see these two are appearing here now you can click click on this CN C+ extension back and click on install I already have this installed so you don't need to do anything else just click on install and it will be installed after you have this cc++ extension pack installed let's create a new folder and write our C code now click on file and click on open folder and let's go to desktop or wherever you want and let's create a new folder I'll call it C test hit select folder and C test is now open and it has no files as you can see here click on this and let's write our first main. C program and here you need to write your C code so let's just write a simple hello world program after you have return return this hello world program just click save and now you can click on this run here and click on run without debugging and you'll have to choose one of these two here click on this first one with GDB / lldb and again click on this ccc.exe now as you can see hello world is printed now let's do this for a C++ program okay now I'll go here and let's create a new code and let's call it main. cppp now again I have this very simple C++ code here you can press contrl s and save this and after that again click on run and click on run without debugging click on C++ here and you are getting this error here so to fix this error just close this and click on this delete to close the terminal and there's a vs code folder that is automatically created just right click on this or click this right click and click on delete and now click on run again and click on run without debugging and here again choose this one and now you'll get these two options so one is ending with GCC the another one with g++ now click on this G+ + one and your code is now running and this main.exe file is now created now to run this you can go here and just type main.exe and hit enter and as you can see Hello word is printed so this is how you can run CN C++ program if you have any questions let me know in the comments below
Info
Channel: The Code City
Views: 1,809
Rating: undefined out of 5
Keywords: setup vscode for c/c++, install c/c++ in vscode, run c/c++ in vscode, run cpp in visual studio code, run c in visual studio code, how to setup vscode for c/c++
Id: AgDlL1Ysm34
Channel Id: undefined
Length: 5min 24sec (324 seconds)
Published: Mon Feb 12 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.