How to Compile and Run C/C++ Programs on MacOS | gcc & VS Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone welcome back to another video in this video i'll be showing how you can compile and run c programs on mac inside vs code so without wasting any time let's get started to compile and run c files on mac you will need two things one is the gcc compiler and the other one is a code editor so for this tutorial we will be using vs code so let's get started first we'll check if gcc is already installed on our system or not to do so we'll just open terminal and inside terminal we'll just type in gcc dash v so it will show us the gcc version now i'll press return as you can see gcc is already installed on my system if you do not have gcc installed on your system you can simply type gcc and then press return in my system gcc is already installed if you do not have it installed it will prompt you to install gcc just click on install now it will take some time and get installed eventually so once you have done that we'll just close this window and create a folder let's name it hello so inside this folder we'll write down our c code so let's open vs code and we will open this folder inside vs code so let me just drag this folder in vs code now the folder is open inside vs code i'll simply go to the extension and here i will search for c as you can see there is a c or c plus plus extension so i'll just simply install this extension so the extension has been installed now i'll close this extension window and i'll go to the file manager so inside this hello folder i'll just create a c file so let's do that i'll name it to hello dot c now i'll write down some test code here i have already written the hello world code so i'll simply copy it and then i will paste it in this file so now i'll just save it by pressing command s so the file is saved now i'll open a terminal let me maximize the window let me make it bigger now we will first compile this file to do so we will run gcc dash pro then we will give a name for our executable file so i'll just call it hello new and then i'll just simply write down the c file which is hello dot c and then i'll press return so as you can see there is a new file created so now we will run this file to run this file we will just specify the file so it will be hello new and just press return as you can see the code has been run successfully so this is how you can run and compile c programs on mac inside vs code thanks for watching see you in the next video bye
Info
Channel: Tech Time
Views: 56,557
Rating: undefined out of 5
Keywords: c/c++, mac, vscode, run, compile, macos, visual, studio, code
Id: siqJWPp50vA
Channel Id: undefined
Length: 4min 16sec (256 seconds)
Published: Mon Apr 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.