How to set up VS Code for C++ and make your First Program? + How I use AI to help me code faster

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi everyone and welcome to my channel in this video i'm going to show you how you can set up and use vs code to make c plus programs some of you asked if that is possible and the answer is absolutely yes so today i will show you a simple and easy way to do that now as some of you already know i personally use visual studio and there are a few reasons for this um first of all i have a free license for visual studio i have a lifelong license from my university but they made a mistake there they probably thought she's going to live for 50 or 60 years so let's give her a lifelong license what a mistake as some of you already know i'm a vegetarian and i lead a very healthy lifestyle so if my calculations are correct i'm going to live for 120 years and i plan to use this free license for my entire life because i paid for my university a lot i'm just kidding i mean i do have a free license but this is not the reason why i use visual studio um because of the nature of my work i have to do a lot of code analyzing a lot of performance testing i have to use a lot of advanced development tools that vs code does not have so basically i need an entire ide for my work but for tutorials for learning purposes uh vs code is going to be more than enough so you can use that and today i want to show you how you can set it up and use it to make c plus programs and then i also want to share some tips on how i use artificial intelligence to help me code faster i know that a lot of people think that ai is very complicated but the tool that i want to show you is actually very simple and it is called tab 9 it is an ai completion tool which means that it basically completes your code for you and then it uses machine learning in order to learn about you and your coding style so the more you use it the more helpful it becomes and i personally use it for c plus and then also for c sharp and javascript because you can use it for all modern programming languages and the best thing is that if you're a student if you use this to learn and save some time while coding your girl has you covered you can use this for free and then if you want to get some additional features customization and things like that you can get a pro plan and i will leave a link in the description so that you can check out all the details for yourself and then later i'm going to show you how you can install and use this tool to help you to code faster so that is what we will do in this video and now i'm going to show you how to set up vs code for c plus plus i'm going to explain every single step of this process so that you know what is happening it's not going to be hard it's very easy but you will have to be careful so that you don't make a mistake because then it is not going to work so as you can see here i have opened visual studio code and the first thing that we need to do is we need to install an extension for c and c plus plus so go to view and then extensions okay and here i'm going to search for c plus plus and you need to install this one so the one from microsoft it's c and c plus plus from microsoft i'm going to click install here okay and it is downloading and installing okay perfect so now after i have installed the extension for c plus plus the next step is to install a compiler and this is because c plus is compiled language which means that the code that you write and that is understandable to you is not understandable to your computer it first needs to be translated or compiled into a language that your computer can understand and for this we use a compiler you can find many different compilers that you can use online the one that i will use is called mingw and i will put the link that you can use to download it in the description it is free so you can use that so let's download our compiler and the download will start shortly after you open the link okay and after this installer is downloaded you are going to click it so you should get a window like this one click next and then here for architecture select the architecture of your computer for me that is 64 and then click next again and then this destination folder i'm going to copy this text so i'm going to select all of this text so ctrl a and then ctrl c because we will need it later and i will just paste it in a basic notepad file okay and then click next and here it starts the downloading and installation process of your compiler so i will be back once this is finished so once the installation is finished click next and then finish and then third step is this path here that i told you we will need later so now i'm going to copy this and what we need to do with this pad is we need to put it inside our environment variables so how you do that well search on your windows for edit environment variables for your account and then open this okay now here you will select this path and then click edit and then here we will need to add the path that we just copied so click new and then here i am going to paste this pad and then here we will need to append something else i will put it on the screen and that is this text here okay so once you have pasted everything it should look something like this and then click ok and then okay here as well and that should be it if you have done everything correctly everything should work perfectly but if you want to make sure that you have installed your compiler successfully what you can do is you can use your command prompt which i will open now and here you are going to type two commands that i will put on the screen as well that is g plus plus version okay and then g d b version like this okay so if you don't don't get any error here that means that everything is installed as it should be but if you get an error here make sure to go back to the previous step and go again through the installation process of your compiler and then make sure that the patch that we copied inside our environment variables is correct okay so let's minimize this and as i said that is everything that you need in order to set up vs code to write c plus programs but one more thing that i promised is i want to show you how you can install and use tab 9 to help you to write faster so for that let's open their site okay i'm going to put the link that you can use in the description so click get tab nine it's free and then here you are going to select your ide i'm going to select vs code okay and here i'm going to click install now and here it should ask you if you want to open this with visual studio code so make sure to select that so i will say open visual studio code and as you can see here we have uh the extension that we need to install so i will click install and it should start installing it now now one very important thing that i want to mention while this is installing is that um if you are installing anything anything in visual studio code make sure to restart your visual studio code after that because sometimes it just gets stuck and it doesn't even realize that something has been installed so after we have installed this i am going to close my visual studio code okay and then uh let's also close this now one thing that i want to do is instead of opening visual studio code manually is i will use this command prompt in order to make a directory where we will put all the files that we create for our program so that everything is organized as it should be so here i'm going to create a folder a directory so i will use um mk there so make directory command in windows and i will create a directory that is called first program like this okay and then after you have created this folder this directory what i want to do is i want to enter inside that directory so i'm going to use cd command and i will say first program so create a first program folder and then enter inside that folder and as you can see this path of my command prompt has changed now we are one folder deeper so inside this first program folder and what i want to do here is i won't say please open my vs code here like this so that is the command that you use and now it should open vs code inside this folder okay perfect um now what i want to do is i want to create a new file and i want to do that inside this first program folder so i will click new file here and then i'm going to name that file for example hello world and then one very important thing is that you will need to use extension dot cpp because you will write source code so you will write inside a file that has extension dot cpp okay so hello world dot cpp and here is our editor and here we are going to write our c plus plus code so let's create a simple hello world program i will say include iostream okay and then using and as you can see immediately tab 9 is offering the completion for this line so using namespace std and you can press stop in order to complete that command and then int main and here i want to say return zero okay and if you see that code appears like magic on this on the screen that is because i'm just using tab in order to complete the lines that are offered by tab nine and here i just want to say c out and then let's say hello okay it is offering already hello world so i'm going to select that so after we have written this very simple hello world program i want to show you how you can compile it and run it using vs code so in order to compile this program you will click on terminal and then here run build task and it should offer something like this and here you are going to select your compiler so make sure to select g plus plus so this one okay and then here it says that build finished successfully and then if you noticed here it created an additional file which is hello world.exe so this is your executable file this is your application so in order to run this file i'm going to open my terminal again and we are positioned inside this first program folder so this is one folder beneath this helloworld.exe so now in order to run this hello world.exe what you need to do is just type hello world dot e x e so not cpp this is one way and then you can also say um dot and then you can use this backslash so dot backslash helloworld.exe and if i press enter as you can see it says hello world okay so that is how you compile and run your program using vs code now let me show you how tab 9 uses artificial intelligence in order to help you to code faster so let's create a variable of type string and let's call it fruit for example and here i want to assign a value of let's say letter a and then letter p and as you can see it is offering me a fruit called apple and that is probably because it reads that the name of the variable is fruit and then it knows to offer a fruit that starts with letter a and then letter p that i typed so an apple okay now let's create another variable let's make it an array called fruits and it will be array of five strings for example and here i want to assign different values so it already offers apple as a first value for my array and then let's say here for example orange and then let's say p e okay it's offering peer and then for example strawberry okay str and then it is offering strawberry and let's say for example banana okay perfect and now let's write out all of these um elements of my array so i will say 4 and then int i is equal to 0 and then i is less than 5 i plus plus again if you see code appearing very fast that is because i'm using tab in order to complete what tab 9 is offering so i will say c out and then fruits of i and let's add end line okay and let me show you one more time how you can compile this program so make sure to save everything and then go to terminal okay terminal and then run build task select g plus plus compiler and when build finishes successfully what you can do is you can run this program in your terminal so you can say hello world dot e x or you can use this approach here so when i press enter as you can see our program works as expected okay one very important thing that i want to mention related to tab 9 is i know that a lot of people will be concerned about privacy and security of their code and this is very important for me personally because i work with very sensitive data and basically when i started working for my company i had to sign a contract that states that i cannot work for another company from the same industry for two years after i stopped working for my current company and that is because all the algorithms all the code and data needs to be very very private so they are probably giving me two years in order to forget it or for them to change it i don't know but basically i had to do a very good research about tab nine and i wouldn't say that all the code that you write stays private and secure so you don't have to worry about that again i will put a link in the description that you can use in order to read more details yourself so that is what i wanted to teach you in this video how you can set up and use vs code in order to write c plus programs and all the details that you will need will be in the description so if you enjoyed this video please give it a thumbs up for the youtube algorithm that helps me a lot to reach more people and teach them programming and then if you have any questions or if you have suggestions for my future videos you can put those in the comments section i made this video because some of you asked me to show you how you can use vs code to make c plus programs and then also let me know in the comments which one will you use from now vs code or visual studio so thank you very much for watching and i'm going to see you in some other video bye
Info
Channel: CodeBeauty
Views: 73,779
Rating: 4.9183993 out of 5
Keywords: how to set up VS Code for C++, first c++ program using vs code, vs code vs visual studio for c++, vs code for c++, compile c++ programs using vs code, run c++ programs using vs code, how i use ai to help me code faster, tabnine, codebeauty, code beauty, c++ programming, c++, how to use vs code for c++, Set up Visual Studio Code for C and C++ Programming, How to Run C and C++ Programs on VS code, C++ Development with VS Code, How to Run C++ in Visual Studio Code on Windows, windows
Id: YgKnzIV4uME
Channel Id: undefined
Length: 17min 1sec (1021 seconds)
Published: Thu Apr 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.