Setting Up Your Machine to Run C Plus Plus Code: A Step-by-Step Guide
The first step in setting up your machine to run C plus plus code is to navigate to the directory where you are storing this file. This can be anywhere on your computer, but it's likely that you'll be going to a directory that is not your desktop. The path will change depending on where you are and what directory you choose.
For example, let's say we're on Mac and we're in this area. We type "cd desktop" and notice that the path changes to our desktop. Then, we type "cd" again and navigate to whatever directory this file is contained in. Maybe you have a folder called "C Plus Tutorial". You can type the first few characters of whatever you want to go to and press tab, and it will auto-fill it.
If you make a mistake and need to go back, simply type "cd .." (the dot dot notation) and press enter. This will bring you back to the parent directory. Now that we're in the correct directory, let's move on to compiling our C plus plus file. To do this, we'll use the command "g++". This will work on both Mac and Windows.
Next, we need to specify the output file name. We can use the "-o" option to do this. For example, if we want the compiled code to be in a file called "run", we would type "g++ -o run program_name_of_the_file_with_cpp". Press enter after typing each command. This will compile our C plus plus file.
Notice that if you make any changes to the code and save it, you'll need to recompile it again to get the updated output. You can do this by pressing the up arrow on your keyboard to cycle through the commands you've already typed. If you're in the same directory and want to compile the same file again with the same output file name, simply rerun the command.
To run the compiled code, we'll use the same command "run" (or whatever name we chose earlier). Notice that if we change the code and save it, we can re-run this command without any issues. This is because the compiled code is stored in an output file with the same name as our C plus plus file.
Using the Up Arrow to Cycle Through Commands
One shortcut we didn't mention earlier is using the up arrow on your keyboard to cycle through commands. When you press the up arrow, it will display the last command you typed. You can then edit it or add to it before pressing enter again. This comes in handy when you're in a situation where you need to make changes to an existing command and don't want to start from scratch.
Conclusion
That's the basics of how to set up your machine to run C plus plus code. We covered everything from navigating to the correct directory to compiling and running our C plus plus file. Remember to go through every step carefully, as this will ensure that you understand each process thoroughly. I also want to apologize for the slower pace of this tutorial - my intention is to provide as much detail as possible so that you don't get stuck or frustrated with common issues.
If you did enjoy this tutorial, please leave a like and subscribe to the channel. I'll see you in another YouTube video.
"WEBVTTKind: captionsLanguage: enhello everybody and welcome to a brand new tutorial series on this channel where i'm going to be covering the c plus language for beginners so this tutorial series is fully suited for anyone who has never used c plus plus before never written any code in their life before that said it obviously will be easier to follow along if you programmed before but i will make sure i explain everything and if you've never programmed before this is the place to be don't worry i will teach you everything you need to know there's going to be no prerequisite information or any tech literacy you really need to know before going through a series like this with that said though this series is titled learn c plus with me or you probably saw that in the thumbnail at least now the idea behind this series which is a little bit different than what i usually do is i am not extremely familiar with c plus plus in fact i just started learning c plus plus the other day and i thought it would be an interesting idea to kind of have a tutorial series where i am learning alongside you so right before i film the video i'm going to mess around with whatever it is that i'm going to be teaching and then immediately hop into the video and start teaching it personally i find the best way to learn is to teach and i just thought this would be kind of a cool series so again just want to be super clear i'm non-expert at c plus i'm gonna do all of the necessary research beforehand to make sure i'm not giving you guys incorrect information but i love explaining stuff to people i love learning a new language and i just thought this would be kind of a fun series and it gives me an opportunity to kind of cover things that i myself found very difficult in the c plus plus language and really focus on them in the tutorial whereas someone who's maybe an expert in c plus plus may have kind of forgotten about what beginners find quite difficult in a new language like this so with that said in this first video here i'm going to discuss how you can compile and run a c plus plus program i'm going to show you how to set up your coding environment whether you're on mac linux or windows and then in future videos we'll actually get into the code and i will go all the way up until object oriented programming in c plus so with that said let's dive in so before i actually get into the install and setup steps i figured it wouldn't be a bad idea to discuss what c plus plus is used for and why you may want to learn so first of all c plus plus kind of gets a reputation of being a very difficult programming language to learn i would argue that it's not that hard to learn especially if you haven't learned another programming language before and it's really not that difficult it's just different than some other languages like python or javascript so don't be intimidated by that if you've heard something like that before this is a great language to start with again not going to be the absolute easiest one to learn but definitely a good option and you're not going to regret learning c plus plus as your first or maybe even second programming language now with that said c plus plus is a very popular programming language it's used by tens of millions of developers it's probably in the top five maybe in maybe even in the top three of the most popular programming languages out there it's been around for a really long time it's used for a ton of different applications it's used for 3d games operating systems compilers interpreters embedded systems desktop applications websites database software i could go on and list about a million things super versatile super fast programming language it's very efficient and performance optimized if you're writing any kind of code where you really care about the execution time of that code then c plus plus is a really good choice for whatever that application or code is going to be so i could go on and on about why you would want to learn c plus plus but just trust me it's a great language you're definitely going to enjoy it learning it and it's super versatile you can do a ton of stuff with it so with that said let's now dive in to the install setup steps so what i'm going to show you how to do specifically is how to install a c plus plus compiler and a code editor that you can actually write your code in so in theory you can write c plus plus code in anything you can write it in notepad you can write it in notepad plus plus you can write it in i don't know what it's called on windows like or not windows or mac whatever their default little text editor is you can write it in that you don't need like a dedicated code editor to write c plus code in however if you want to get nice syntax highlighting you want to get auto complete and some other just nice features to have when you're writing code you're going to want to install a text editor or a ide so like something like visual studio code if you don't know what that is don't worry about it in this tutorial series i'm going to be using a text editor called sublime text this is a really lightweight really minimalist text editor i really like it for doing basic tutorials and i would recommend if you're someone who's just starting out and you don't kind of know about any other text editors or ide just go with the sublime text editor it's free and you can get it from the link in the description so just download this sublime text editor and then open it up and you will now have an environment in which you can write code in now if you're on windows your install steps are going to be a little bit different than if you're on mac so if you're on mac windows or linux you need a text editor or you need something to write your code in so pick whatever that is that you want i recommend recommend sublime text for this tutorial and then if you're on mac your setup is done you actually already have a c plus compiler installed on your computer i'll show you how to access that in a minute if you're on linux same thing you already have a compiler in your system however if you're on windows you do not so you need to install one so there's this thing called ming gw not really going to get into exactly what this is but go to the link in the description download this run through the installer if you see any options just leave them completely default the only thing you should change if you want to is the install location of this program make sure when you install this you keep track of where you install it so if you installed on a different drive or something like that just make sure you know where it is because we are going to need to find the actual location of this on our on our disk or i guess on our drive so go ahead run through this install again link in the description once it's installed you need to make sure you remember where you installed okay so now that you have this installed assuming you're on windows again if you're on mac you can kind of fast forward a bit until this is done what you want to do is you want to find this program from your file explorer so open up your file explorer go to your drive i'm going to go to this pc i'm going to go to my c drive this is where i installed my program and just go and locate wherever you installed so it should be by default in your c drive in program files x86 and then you should scroll down and you should see the ming gws ming gw64 now go inside of all these folders that i'm showing you so go inside of this one go inside of the ming gw folder then go inside of bin so again this is specific if you're on windows now what you want to do is you want to get the path to this bin notice here there's all kind of executable files here these are actually a bunch of different interpreters that you can use for other programming languages or sorry not interpreters compilers so you can see g plus plus this is one that we're actually going to use for this video right here again you don't need to worry about all of this but just find this install location so if you click on your little bar here you can copy this install location so copy it to your clipboard now that you have this installed what you need to do is you need to go and modify your path variable now a path is just kind of a list of all of the locations to different executable files on your machine now the reason we need to add this right here to our path is so that we can actually use the c plus compiler from our command line you'll see how this works in a second but what you're going to type here in your windows search bar is just path now it should pop up this thing that says edit the system environment variables you want to go to a tab that looks like this again you could type in edit the system environment variables open this up what you're going to see is you have all of these different tabs go to the advanced tab go to environment variables and then you should see something that says path now when you're on path what you're going to do is you're going to press edit you're probably going to see a ton of other stuff inside of here what you want to do now is you want to add the path to this install location so whatever you just installed you want to add the path to that that's the path we just copied so we're going to press new and then we're just going to paste in that path that we have you can see i already have mine here so i'm not actually going to do this but just go ahead and paste it in so let me just remove that because i don't need it twice so once that is in there you're going to press ok and then you're going to press ok again and then if apply is able to be pressed press apply it probably won't be then you just press ok now what you've done is you've added the path to that install location so now any of those files that were in that bin you can now access them without having to type out their entire path from your command prompt so now on windows what you want to do to test that this is working is open up your command prompt and you want to type g plus plus now g plus plus is a c plus plus compiler which i will discuss in a second so you type g plus plus and just press enter if you get some type of output even if it says fatal error that's totally fine that is good if you see something that says g plus plus is not a recognized command you need to make sure you follow along with the steps i just showed you and that you added this to the path try to restart your command prompt and then boot it up again and see if this works but it should work after you go through those steps so now you should have your cbos plus compiler installed and we're ready to actually go ahead and start writing some code so at this point in time all of the mac people you can start listening again uh you will have this g plus plus compiler on your machine by default so you guys should open up your terminal you should type g plus plus in here and you should see if that works now again that just should work if you're on macro linux i don't know why that wouldn't work that should work for you and then we're kind of ready to go so now this is a good point for me to discuss what i mean by compiler because i keep saying this word compiler you've probably heard me say interpreter 2 a compiler kind of takes the source code that we write and it transcribes it or translates it into a binary executable file so by default whenever you write c plus code you can't just run that code that is just you know plain text on your computer the computer doesn't understand that so what the compiler does is it takes this code it translates it into machine language or into a binary language that a uh that your computer can actually understand and that it can run so what's going to happen is every time we write our code whenever we want to run it we're going to compile the code translate it into this new file and then this new file will have our program in a binary format we will then run that program and there we go we'll run that file that will run our program and we will be good to go so that is the difference between c plus plus and some other programming languages say like python you wouldn't have to do something like this okay so hopefully that makes sense uh that is what i mean by compiler so now what we're going to do is we're going to write our very first c plus program so you're going to open up subline text on whatever editor or whatever operating system you're using or if you're not using subline text open up your editor and create a new file now this new file you create must have a dot cpp file extension cpp stands for c plus plus so whenever you write your c plus code you're going to put it in a dot cpp file now if you're working in a text editor like sublime text as soon as you start typing you'll notice your text is going to be highlighted in different colors that kind of tells you that you're getting syntax highlighting in that this editor recognizes that the code that you're writing is c plus plus code so we will continue the tutorial in one second but i need to quickly thank the sponsor of this video and this series which is algo expert algo expert is the best platform to use for preparing for your software engineering coding interviews they have over 140 coding interview questions on the platform which are just the highest quality resources you can use to prepare for your technical coding interviews so with that said get started using algo expert today by clicking the link in the description and using the code tech with tim for a discount on the platform so what we're going to do is write a really standard hello world program i'm not really going to explain what i'm writing just write it out here this is just the test that our environment is set up so what we're going to do is the following we're going to say include and then inside of angle brackets we're going to say io stream like that then underneath this line what we're going to type is using namespace std you might get this autocomplete if you're working in in sublime text and then we're going to put a semicolon at the end of this line a semicolon is a terminator it tells you that whatever statement you just wrote is now terminated now what these two lines are kind of doing is they're saying we're going to include a library that allows us to actually print information to the console and this namespace is going to give us access to things that are in the standard uh c plus plus library so just like pieces of syntax again you don't have to know what that means just trying to give you a bit of information now we're going to create a function we're going to say int main we're going to put two parentheses like this and then we're gonna put two curly braces and inside of here we're gonna write the following line we're gonna write c out we're gonna write these two things right here i think these are less than signs although i always mix up if they're less than or greater than you're gonna write two of these here and then you're gonna put inside of quotation marks make sure they're double quotation marks hello world exclamation point semicolon and then on the next line you're going to say return 0. now as soon as we get through a few videos here all of this will make perfect sense you will know this like the back of your hand but for right now just kind of take for granted the fact that this is going to print something out to the console and this is our very first c plus plus program all this is going to do is print this hello world so when we run this code all we're going to see is that a little bit of textures of the console that says hello so go ahead and save that control s and then what you want to do is you want to compile this file so to compile this file you need to open up your terminal or your command prompt depending on the operating system you're on and you need to navigate to the directory you're storing this file in so i've created a folder on my desktop it's called c plus plus tutorial inside i have my file tutorial1.cpp so open up your terminal open up your command prompt and you need to use the cd command which stands for change directory to get into the directory where this file is contained so a little bit of a shortcut if you're on windows here is if you just go to the directory from your file explorer like you normally would so let's go to c plus plus tutorial and then you go here so this little search bar and you delete all of this and you type cmd this will open up the command prompt in this location so notice the location is where we just where and then you're good to go so if you're on mac you're probably going to be in some directory that is not your desktop you're probably going to be in your user's home directory which means you should have something like users and then whatever your name is or something like that so what you're going to do is you're going to navigate to wherever you're storing this file so if it's on your desktop for example you're going to type cd desktop and then that's going to bring you to your desktop so let's actually just go ahead and do this ignore the two lines i just typed let's say i'm on mac and i'm in this this area i type cd desktop i go to my desktop notice now the path changes the desktop then i'm going to type cd and i'm going to go to whatever directory this file is contained in so maybe you have a folder called c plus tutorial by the way you can type the first few characters of whatever you want to go and press tab and it should auto fill it so if i do c and then tab it auto fills c tutorial so go ahead and press enter and now from here you should be good to go so just navigate using cd which stands for change directory to the directory you want to go to if you make a mistake and you need to go back type cd dot dot this will bring you back to the parent directory so we'll move you back one notice here this moves me from c swiss tutorial back to desktop anyways i have this uh command prompt open in this directory now what i'm going to do is compile my c plus file to do this i'm going to type g plus this will work on both mac and windows i'm going to type hyphen o which i believe stands for out then i'm going to type the name of the file that i want to contain the compiled code so the name of the file i want to run i'm going to call this run or i'll call this like run program or something call it whatever you want doesn't matter and then after this you're going to put the name of the file you want to compile in this case the name of my file is tutorial1 so whatever you named your file you put here and then you press enter so g plus plus hyphen o run program name of the file that contains the code you wrote dot cpp press enter you're gonna see that you're gonna get no output if you get no output that is good now what you can do is you can type this name right here that contains the kind of output file so i'm going to say run program and just press enter when you do that you should see that hello world pops up on the screen if you're on mac or linux type dot slash run program and that should work so either of them should probably work but on mac and linux i'm not sure because i haven't done this you probably need to type dot slash and that should then run the file for you but you can run this as many times as you want it contains the compiled code now just notice something here if i change this what i'm kind of printing out to the screen to just say hello and i save this file and then i go ahead and i try to run this code again so i do run program notice it's still printing hello world the reason for this is i have not recompiled my code so what i need to do to recompile my code or to get this program to now be updated with the new code i wrote is i need to compile it again so a little shortcut here if you press the up arrow on your keyboard this will cycle through the commands you've already typed so since i'm already in the same directory and i just want to compile the same file again and i want it to go to the same output file i'll just rerun this command so now that i rerun this command it should recompile my code or compile it again and now what i can do is just type the name of that program so we'll say run program and now notice it just says hello so there you go that is the basics of how to set up your machine to run c plus plus code so that is all i had for tutorial one i apologize this was a little bit slow i just want to make sure i go through every single possible edge case and thing that could go wrong so you guys can follow along and aren't getting frustrated and stuck at a ton of things you'll probably notice with my tutorials i'm very verbose i go through everything and i just want to make sure i'm giving you as much information as i can so that this is the only resource you need to go to you don't need to go and look up a million things after the video because i didn't cover them so with that said i hope you guys enjoyed if you did make sure you leave a like subscribe to the channel i will see you in another youtube videohello everybody and welcome to a brand new tutorial series on this channel where i'm going to be covering the c plus language for beginners so this tutorial series is fully suited for anyone who has never used c plus plus before never written any code in their life before that said it obviously will be easier to follow along if you programmed before but i will make sure i explain everything and if you've never programmed before this is the place to be don't worry i will teach you everything you need to know there's going to be no prerequisite information or any tech literacy you really need to know before going through a series like this with that said though this series is titled learn c plus with me or you probably saw that in the thumbnail at least now the idea behind this series which is a little bit different than what i usually do is i am not extremely familiar with c plus plus in fact i just started learning c plus plus the other day and i thought it would be an interesting idea to kind of have a tutorial series where i am learning alongside you so right before i film the video i'm going to mess around with whatever it is that i'm going to be teaching and then immediately hop into the video and start teaching it personally i find the best way to learn is to teach and i just thought this would be kind of a cool series so again just want to be super clear i'm non-expert at c plus i'm gonna do all of the necessary research beforehand to make sure i'm not giving you guys incorrect information but i love explaining stuff to people i love learning a new language and i just thought this would be kind of a fun series and it gives me an opportunity to kind of cover things that i myself found very difficult in the c plus plus language and really focus on them in the tutorial whereas someone who's maybe an expert in c plus plus may have kind of forgotten about what beginners find quite difficult in a new language like this so with that said in this first video here i'm going to discuss how you can compile and run a c plus plus program i'm going to show you how to set up your coding environment whether you're on mac linux or windows and then in future videos we'll actually get into the code and i will go all the way up until object oriented programming in c plus so with that said let's dive in so before i actually get into the install and setup steps i figured it wouldn't be a bad idea to discuss what c plus plus is used for and why you may want to learn so first of all c plus plus kind of gets a reputation of being a very difficult programming language to learn i would argue that it's not that hard to learn especially if you haven't learned another programming language before and it's really not that difficult it's just different than some other languages like python or javascript so don't be intimidated by that if you've heard something like that before this is a great language to start with again not going to be the absolute easiest one to learn but definitely a good option and you're not going to regret learning c plus plus as your first or maybe even second programming language now with that said c plus plus is a very popular programming language it's used by tens of millions of developers it's probably in the top five maybe in maybe even in the top three of the most popular programming languages out there it's been around for a really long time it's used for a ton of different applications it's used for 3d games operating systems compilers interpreters embedded systems desktop applications websites database software i could go on and list about a million things super versatile super fast programming language it's very efficient and performance optimized if you're writing any kind of code where you really care about the execution time of that code then c plus plus is a really good choice for whatever that application or code is going to be so i could go on and on about why you would want to learn c plus plus but just trust me it's a great language you're definitely going to enjoy it learning it and it's super versatile you can do a ton of stuff with it so with that said let's now dive in to the install setup steps so what i'm going to show you how to do specifically is how to install a c plus plus compiler and a code editor that you can actually write your code in so in theory you can write c plus plus code in anything you can write it in notepad you can write it in notepad plus plus you can write it in i don't know what it's called on windows like or not windows or mac whatever their default little text editor is you can write it in that you don't need like a dedicated code editor to write c plus code in however if you want to get nice syntax highlighting you want to get auto complete and some other just nice features to have when you're writing code you're going to want to install a text editor or a ide so like something like visual studio code if you don't know what that is don't worry about it in this tutorial series i'm going to be using a text editor called sublime text this is a really lightweight really minimalist text editor i really like it for doing basic tutorials and i would recommend if you're someone who's just starting out and you don't kind of know about any other text editors or ide just go with the sublime text editor it's free and you can get it from the link in the description so just download this sublime text editor and then open it up and you will now have an environment in which you can write code in now if you're on windows your install steps are going to be a little bit different than if you're on mac so if you're on mac windows or linux you need a text editor or you need something to write your code in so pick whatever that is that you want i recommend recommend sublime text for this tutorial and then if you're on mac your setup is done you actually already have a c plus compiler installed on your computer i'll show you how to access that in a minute if you're on linux same thing you already have a compiler in your system however if you're on windows you do not so you need to install one so there's this thing called ming gw not really going to get into exactly what this is but go to the link in the description download this run through the installer if you see any options just leave them completely default the only thing you should change if you want to is the install location of this program make sure when you install this you keep track of where you install it so if you installed on a different drive or something like that just make sure you know where it is because we are going to need to find the actual location of this on our on our disk or i guess on our drive so go ahead run through this install again link in the description once it's installed you need to make sure you remember where you installed okay so now that you have this installed assuming you're on windows again if you're on mac you can kind of fast forward a bit until this is done what you want to do is you want to find this program from your file explorer so open up your file explorer go to your drive i'm going to go to this pc i'm going to go to my c drive this is where i installed my program and just go and locate wherever you installed so it should be by default in your c drive in program files x86 and then you should scroll down and you should see the ming gws ming gw64 now go inside of all these folders that i'm showing you so go inside of this one go inside of the ming gw folder then go inside of bin so again this is specific if you're on windows now what you want to do is you want to get the path to this bin notice here there's all kind of executable files here these are actually a bunch of different interpreters that you can use for other programming languages or sorry not interpreters compilers so you can see g plus plus this is one that we're actually going to use for this video right here again you don't need to worry about all of this but just find this install location so if you click on your little bar here you can copy this install location so copy it to your clipboard now that you have this installed what you need to do is you need to go and modify your path variable now a path is just kind of a list of all of the locations to different executable files on your machine now the reason we need to add this right here to our path is so that we can actually use the c plus compiler from our command line you'll see how this works in a second but what you're going to type here in your windows search bar is just path now it should pop up this thing that says edit the system environment variables you want to go to a tab that looks like this again you could type in edit the system environment variables open this up what you're going to see is you have all of these different tabs go to the advanced tab go to environment variables and then you should see something that says path now when you're on path what you're going to do is you're going to press edit you're probably going to see a ton of other stuff inside of here what you want to do now is you want to add the path to this install location so whatever you just installed you want to add the path to that that's the path we just copied so we're going to press new and then we're just going to paste in that path that we have you can see i already have mine here so i'm not actually going to do this but just go ahead and paste it in so let me just remove that because i don't need it twice so once that is in there you're going to press ok and then you're going to press ok again and then if apply is able to be pressed press apply it probably won't be then you just press ok now what you've done is you've added the path to that install location so now any of those files that were in that bin you can now access them without having to type out their entire path from your command prompt so now on windows what you want to do to test that this is working is open up your command prompt and you want to type g plus plus now g plus plus is a c plus plus compiler which i will discuss in a second so you type g plus plus and just press enter if you get some type of output even if it says fatal error that's totally fine that is good if you see something that says g plus plus is not a recognized command you need to make sure you follow along with the steps i just showed you and that you added this to the path try to restart your command prompt and then boot it up again and see if this works but it should work after you go through those steps so now you should have your cbos plus compiler installed and we're ready to actually go ahead and start writing some code so at this point in time all of the mac people you can start listening again uh you will have this g plus plus compiler on your machine by default so you guys should open up your terminal you should type g plus plus in here and you should see if that works now again that just should work if you're on macro linux i don't know why that wouldn't work that should work for you and then we're kind of ready to go so now this is a good point for me to discuss what i mean by compiler because i keep saying this word compiler you've probably heard me say interpreter 2 a compiler kind of takes the source code that we write and it transcribes it or translates it into a binary executable file so by default whenever you write c plus code you can't just run that code that is just you know plain text on your computer the computer doesn't understand that so what the compiler does is it takes this code it translates it into machine language or into a binary language that a uh that your computer can actually understand and that it can run so what's going to happen is every time we write our code whenever we want to run it we're going to compile the code translate it into this new file and then this new file will have our program in a binary format we will then run that program and there we go we'll run that file that will run our program and we will be good to go so that is the difference between c plus plus and some other programming languages say like python you wouldn't have to do something like this okay so hopefully that makes sense uh that is what i mean by compiler so now what we're going to do is we're going to write our very first c plus program so you're going to open up subline text on whatever editor or whatever operating system you're using or if you're not using subline text open up your editor and create a new file now this new file you create must have a dot cpp file extension cpp stands for c plus plus so whenever you write your c plus code you're going to put it in a dot cpp file now if you're working in a text editor like sublime text as soon as you start typing you'll notice your text is going to be highlighted in different colors that kind of tells you that you're getting syntax highlighting in that this editor recognizes that the code that you're writing is c plus plus code so we will continue the tutorial in one second but i need to quickly thank the sponsor of this video and this series which is algo expert algo expert is the best platform to use for preparing for your software engineering coding interviews they have over 140 coding interview questions on the platform which are just the highest quality resources you can use to prepare for your technical coding interviews so with that said get started using algo expert today by clicking the link in the description and using the code tech with tim for a discount on the platform so what we're going to do is write a really standard hello world program i'm not really going to explain what i'm writing just write it out here this is just the test that our environment is set up so what we're going to do is the following we're going to say include and then inside of angle brackets we're going to say io stream like that then underneath this line what we're going to type is using namespace std you might get this autocomplete if you're working in in sublime text and then we're going to put a semicolon at the end of this line a semicolon is a terminator it tells you that whatever statement you just wrote is now terminated now what these two lines are kind of doing is they're saying we're going to include a library that allows us to actually print information to the console and this namespace is going to give us access to things that are in the standard uh c plus plus library so just like pieces of syntax again you don't have to know what that means just trying to give you a bit of information now we're going to create a function we're going to say int main we're going to put two parentheses like this and then we're gonna put two curly braces and inside of here we're gonna write the following line we're gonna write c out we're gonna write these two things right here i think these are less than signs although i always mix up if they're less than or greater than you're gonna write two of these here and then you're gonna put inside of quotation marks make sure they're double quotation marks hello world exclamation point semicolon and then on the next line you're going to say return 0. now as soon as we get through a few videos here all of this will make perfect sense you will know this like the back of your hand but for right now just kind of take for granted the fact that this is going to print something out to the console and this is our very first c plus plus program all this is going to do is print this hello world so when we run this code all we're going to see is that a little bit of textures of the console that says hello so go ahead and save that control s and then what you want to do is you want to compile this file so to compile this file you need to open up your terminal or your command prompt depending on the operating system you're on and you need to navigate to the directory you're storing this file in so i've created a folder on my desktop it's called c plus plus tutorial inside i have my file tutorial1.cpp so open up your terminal open up your command prompt and you need to use the cd command which stands for change directory to get into the directory where this file is contained so a little bit of a shortcut if you're on windows here is if you just go to the directory from your file explorer like you normally would so let's go to c plus plus tutorial and then you go here so this little search bar and you delete all of this and you type cmd this will open up the command prompt in this location so notice the location is where we just where and then you're good to go so if you're on mac you're probably going to be in some directory that is not your desktop you're probably going to be in your user's home directory which means you should have something like users and then whatever your name is or something like that so what you're going to do is you're going to navigate to wherever you're storing this file so if it's on your desktop for example you're going to type cd desktop and then that's going to bring you to your desktop so let's actually just go ahead and do this ignore the two lines i just typed let's say i'm on mac and i'm in this this area i type cd desktop i go to my desktop notice now the path changes the desktop then i'm going to type cd and i'm going to go to whatever directory this file is contained in so maybe you have a folder called c plus tutorial by the way you can type the first few characters of whatever you want to go and press tab and it should auto fill it so if i do c and then tab it auto fills c tutorial so go ahead and press enter and now from here you should be good to go so just navigate using cd which stands for change directory to the directory you want to go to if you make a mistake and you need to go back type cd dot dot this will bring you back to the parent directory so we'll move you back one notice here this moves me from c swiss tutorial back to desktop anyways i have this uh command prompt open in this directory now what i'm going to do is compile my c plus file to do this i'm going to type g plus this will work on both mac and windows i'm going to type hyphen o which i believe stands for out then i'm going to type the name of the file that i want to contain the compiled code so the name of the file i want to run i'm going to call this run or i'll call this like run program or something call it whatever you want doesn't matter and then after this you're going to put the name of the file you want to compile in this case the name of my file is tutorial1 so whatever you named your file you put here and then you press enter so g plus plus hyphen o run program name of the file that contains the code you wrote dot cpp press enter you're gonna see that you're gonna get no output if you get no output that is good now what you can do is you can type this name right here that contains the kind of output file so i'm going to say run program and just press enter when you do that you should see that hello world pops up on the screen if you're on mac or linux type dot slash run program and that should work so either of them should probably work but on mac and linux i'm not sure because i haven't done this you probably need to type dot slash and that should then run the file for you but you can run this as many times as you want it contains the compiled code now just notice something here if i change this what i'm kind of printing out to the screen to just say hello and i save this file and then i go ahead and i try to run this code again so i do run program notice it's still printing hello world the reason for this is i have not recompiled my code so what i need to do to recompile my code or to get this program to now be updated with the new code i wrote is i need to compile it again so a little shortcut here if you press the up arrow on your keyboard this will cycle through the commands you've already typed so since i'm already in the same directory and i just want to compile the same file again and i want it to go to the same output file i'll just rerun this command so now that i rerun this command it should recompile my code or compile it again and now what i can do is just type the name of that program so we'll say run program and now notice it just says hello so there you go that is the basics of how to set up your machine to run c plus plus code so that is all i had for tutorial one i apologize this was a little bit slow i just want to make sure i go through every single possible edge case and thing that could go wrong so you guys can follow along and aren't getting frustrated and stuck at a ton of things you'll probably notice with my tutorials i'm very verbose i go through everything and i just want to make sure i'm giving you as much information as i can so that this is the only resource you need to go to you don't need to go and look up a million things after the video because i didn't cover them so with that said i hope you guys enjoyed if you did make sure you leave a like subscribe to the channel i will see you in another youtube video\n"