In this video, I'll show you how to use the source code provided for the course in Visual Studio code.
So the first thing we need to do is we need to get the source code and the source code is in the course
and you can see here in the course content and if you scroll all the way to the bottom, you'll see
section 22, extra information source code and other stuff right here and right in there, you'll see
source code for all sections.
So if you click on that, you're going to see the source code that's going to be downloadable here,
and each one of these is going to be a zip file for each section of the course.
Now, as I'm making this video, this is in section 22.
When you all watch this video, most likely this will be way down here, section 25 or 26 or 27 or somewhere
down at the bottom of the content, because the new lectures that I'll put in the course will be inserted
in here.
So anyway, just look for extra information and then source code for all sections and you'll find it.
And then once you do that, you can download the source code.
So for example, I'm going to download section four right here and I'm just going to click on there
and then I'm going to save that to my desktop.
I've already done that and you can extract it to the desktop as well.
So the idea is create a section for folder on my desktop.
Now I say my desktop, you can do this anywhere you like.
I'm just putting it on my desktop just to make it easier to show you.
So I've already done that and if you come over here you can see my desktop.
There is the section for folder that I unzipped and there are the contents of the folder.
You'll notice this is a code like structure and that's okay, Visual Studio code, we'll just ignore
that.
But I've got one, two, three, four, five, six, seven projects inside this folder.
So I think you know what to do.
You go over to Visual Studio code and you open up the section for folder.
So let's do that right now.
So here's Visual Studio code and I'm just going to open the folder and I'm going to open up the section
for folder on my desktop.
So I'm just going to select that folder and it's going to open it up just like we did when we created
our.
Now again, you'll notice this code light information Makefile.
You can delete this folder and you can delete these two files if you like.
I wouldn't delete them.
I would just leave them in there in case you ever want to use code like they're there, so you might
as well keep them there.
So we can't do anything yet.
Remember, we need to create the V code folder with the launch json test, JSON and CP properties file.
We only have to do that once per project.
So once we include this section for folder, now we have to set that up and then after that we're good
to go.
We can compile and build any of these projects a couple of ways we can do this.
We can do it the same way that we did it in the previous videos, right?
I could just do it manually and create them.
That's pretty easy and that's what I'm going to do now, just so that you can see it one more time,
you can also just copy and paste that vs code folder that you've already created in that other project
that we did.
Just copy it right in here and it'll be good to go.
All right.
So what I'm going to do is, like I said, I'm going to create it from scratch, just like we did before.
So I'm just going to open up any one of these guys and select that main.
CP That's important.
And then what I'm going to do is I'm going to come up here to view the command palette and select again,
that's edit configurations UI.
If that doesn't show up, just type C++ and it will show up somewhere in here.
That's what I'm going to choose.
We'll do just like before.
We'll change this GC to G Plus Plus and we'll come down here and we'll set the compiler standard to
C++ 17 right there.
That's it.
I'm saving that.
And now you can see that it's created the V code folder with that CP properties JSON file.
Pretty good.
So we're done with that.
I'm just going to close this up.
The next thing we'll do is we need to create the task JSON file, so we'll come over here to terminal
and configure default build task.
What are we using?
We're using G plus plus right here and that's going to create my test JSON file.
What I can do here is just like we did before, I want to add my warnings.
I want to add the C++ 17 standard.
I want to change line 12 here, which is the file to file your name just like that.
And I just want to add slash slash star DHCP so it compiles all the files.
That's it.
We're done with that.
So at this point we can build and run a project.
So let's run this first program right here.
So again, I can select close test JSON, I can select that main CP and I can come up with the terminal,
run the build test and we should get a clean compile that we do.
And you can see right here or my mouse is that it's doing first program.
That's that project right there, that folder and it finished successfully.
If I want to run the XY file which was created, you can see it's created right there.
I can right click on that, open it in the integrated terminal and just type dot slash main XY.
Enter your favorite number between one and 150.
Amazing.
That's my favorite number too.
Just like what the source code says up here.
So that's it.
We're done.
We can run any of the other programs in any of the other folders the same way.
Now, what we're going to do is we're going to set up the debugger.
So we're going to set up our debugger so that we can debug as well.
So what we do now is we go up to run add configuration, we're going to select g plus plus gdb lib.
We're going to slight G plus plus again and we're going to get this running when it's done, just kill
it right here with that little red box because we're not interested in running it right now.
What we do want to do is we want to modify this launch JSON file and all we're doing is we're taking
this file, your name right here, including the dollar and the curlies, just like that.
I'm copying it and I'm pasting it into here.
Just like that.
And that's it.
We're done with that.
If you make mistakes here, let's say you forget that that close quote, you're going to get squiggles
and stuff will turn red.
So make sure you don't see any of that.
Everything looks nice and nice and clean like this.
No squiggly lines, no red errors or anything like that.
When we're done, we can save it and I can close that up.
And now let's say I'm here.
And so if I want to debug this program, I would select the main CP file and I would click on this bug
right here.
If you have any breakpoint set down here, you can just delete them all, as I showed you before.
And now we're going to set a breakpoint, let's say, right there.
And once we're good to go, we just press this green arrow right here and our program will start in
the debugger.
You can see I've got a variable favorite number here and you can see its value is zero.
Its value is actually undefined because I haven't defined it, but the debugger is putting a zero in
there that could be any value in there.
That's it.
Now if I want to execute line eight, which is where I'm stopped at, I would just click this button
right here, step over, and now it's asked me, enter your favorite number and it's just waiting me
to type something in.
I'll type in 45 and press enter.
Now I'm at the next line.
You can see that now favorite number is 45 and I can continue here.
I can stop the program, I could do whatever I like.
That's it.
Program is finished.
I can go back to my explorer and execute another program here.
So there you go.
This is how you would use the provided source code with Visual Studio code.
So at this point, you have everything you need to be able to work in code light or in Visual Studio
code.
Some students prefer code light, other students prefer Visual Studio code, and now you've got the
tools to do it both ways.