How to Set up Visual Studio Code for C and C++ Programming: Install MinGW w64 compiler & VS Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
What's up guys. In this video, I'm gonna  show you how to set up or configure Visual   Studio code for C and C plus plus programming so  that you can start cording with C or C plus plus   programming in Visual Studio code. For this,  you need to install two things. The first one   is MinGW compiler and the second one is Visual  Studio code. So let's begin by installing MinGW   compiler. So MinGW basically is the most popular  and the best compiler for C and C plus plus   programming in Windows. So let's get to the  point and install the compiler. Therefore,   open your browser and type in MinGW and hit enter.  Here click the first link from sourceforge.net.   Click on download and wait  for a couple of minutes. Once it finished downloading,  here click on open folder. This is my MinGW setup file. So double click  on the setup to install. This opens up the   installer window. So click on install. This is  the default directory, so I would keep it as it   is and click continue. Wait for some time until  it finish downloading important features. Now   my download is complete. So click on continue.  This opens up the MinGW installation manager.   So in the MinGW installation manager, there are  different packages that are going to be added.   So here right click on the first package  and click on Mark for installation and   do it for all packages so that they  will be included in your MinGW. After selecting all the packages, go  to installations and click on apply   changes. Now click on apply. Wait for a  couple of minutes to get it installed. Now our download manager completed downloading  and extracting all the important packages to the   MinGW. So click on close. Now let's add the path  of the MinGW compiler so that our system actually   knows the compiler. So go to your C drive and here  you can see the MinGW. Click on it. In the MinGW,   click on bin and copy the path by right clicking  here. it's important as it helps us to compile   our code from anywhere in our system. Now go to  the taskbar and search for environment variables.   So type in environment variables and click on  this environment variables option. This opens   up the environment variables window. Click  on environment variables. So click on path   then edit. Here simply click on new  and paste the path that we copied.   Click on OK. Again ok. Now we finished installing  our MinGW compiler for C and C plus plus   programming. So let's see if our MinGW compiler  is correctly installed. So go to the search bar   and type in CMD to open the command prompt and on  the command prompt window, type in GCC space dash   dash version and hit enter. Here you can see that  our compiler is correctly installed. Now let's   install the IDE that is VS code. So to install it,  open up your browser and on the URL bar type in   code.visualstudio.com and hit enter. This opens up  the official site of Visual Studio code where you   can download the installer. Here it automatically  identifies my Windows operating system.   If you want to download it for a different  operating system other than the windows,   you can click the down arrow and select the option  for your operating system. So to download it for   Windows, simply click on download for Windows  and wait for a couple of seconds until the setup   for the installer is fully downloaded. Once it  finished downloading, click on open folder. Now   double click on this set up file to install. Here  simply accept the agreement and click on next. Now keep the default location  as it is and click on next.   Again next. Here it's important to check the  first option to create a desktop icon and   check this option to add the open with code  action to Windows Explorer File context menu   and finally check this option to enable  the same option for directory context menu   and then click on next. Now simply click on  install and it's going to start installing   and finally click on finish. This launches the  visual studio code. So we have Visual Studio code   ready for coding in our system. Once we finished  installing MinGW compiler and visual studio code,   let's directly dive into setting up vs  code for C and C plus plus programming.   So open up the visual studio code by typing  in Visual Studio code at your search bar or   the visual studio code shortcut. This opens  up the visual studio code welcome screen.   Now on the left hand side, go to extensions and  click on it. Here in the search bar type in C   C++ and click on the C C plus plus extension  published by Microsoft. Click on install. This extension provides the language support  for C and C plus plus to visual studio code.   Wait for the extension to finish installing.  Once it's finished installing this extension,   once again go to the search bar and type in code  Runner to install one more important extension.   This extension will help you to run  C and C plus plus programs easily by   just clicking on a single button. Now  go to code Runner and click on install. Now this extension is installed successfully. Next   restart the visual studio code.  So close it and open it up again. Now let's set up the workspace by adding a folder.   So go to file and click on  add folder to workspace. You can create a folder anywhere in your PC and  add it to the workspace. I'm gonna put it in my   desktop, create a new folder here and name it C  and CPP files. Now select the folder and add it. Here you can see the folder we have created.   You can also save the workspace with the  name of your choice. For that go to file   and click on Save workspace as and it opens  up a window where you can name your workspace.   So I'm gonna save it in my desktop with a  name let's say, c c plus plus programming   and click on Save. Now you can see that we  have the workspace which contains the folder   we have already created. Now let's create  a file inside the folder. So select this   folder and click on this new file button.  Name the file with let's say, Hello.c. So the file Hello.c is opened here. Now  let's create a simple Hello World program.   If you are new to C programming and curious  about how we have written this program,   you can watch my video tutorials on C  programming. But for now let's focus   on how we can run C programs in Visual Studio  code. So to run this program you have a couple   of options to use. The first option is that you  can go to the top right corner and click on this   run code icon. The second option is you can use  keyboard shortcuts that is press Ctrl alt N and it   will run the program or the third option is that  you can right click here and click on run code.   Now you can see here in the output tab that the  output is displayed which is Hello World. Alright,   so we are now able to run a simple C program that  simply displays an output. But what if you write a   program that needs a user input? In this case you  can't enter an input from this output tab because   this output tab is read only. So let's test it  by writing a program that demands a user input. Now run this program and you can see that  it doesn't display anything in the output   tab as the output tab is read only.  So the solution is stop this program   by pressing alt Ctrl M on your keyboard and  configure the settings. Therefore, go to file   and go all the way down to preferences, then  select settings and click on extensions.   Now go all the way down to run  code configuration and click on it. Then scroll down to run in terminal and  check it. Save it by pressing Ctrl + S on   your keyboard and close the settings.  Now come back to the code and run it.   Here the code runs and it says enter number.  Let's say 78 and it says the number is 78.   So you are now all set to run any C or C plus  plus programs on Visual Studio code. Thanks   for watching and if you like the video,  show me by liking sharing and subscribing.
Info
Channel: Kerim Academy
Views: 11,456
Rating: undefined out of 5
Keywords: visual studio code, set up visual studio code for c c++, how to run c program in visual studio code, how to install visual studio code, how to run c in visual studio code, visual studio, run c program in visual studio code, how to run c in visual studio code on windows 10, how to set up visual studio code for c programming, how to set up visual studio code for c and c++ programming, set up visual studio code for c and c++ programming, run c in visual studio code
Id: jWN1Q9ZIytM
Channel Id: undefined
Length: 9min 32sec (572 seconds)
Published: Wed Sep 20 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.