(lively electronic music)
(keyboard keys clack)
Frank: 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 gonna see the source code
that's gonna 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 gonna click on there.
And then I'm gonna 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 four 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 four folder that I unzipped.
And there are the contents of the folder.
You'll notice this is a CodeLite structure,
and that's okay,
Visual Studio Code will 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 four 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 four folder on my desktop.
So I'm just gonna select that folder.
And it's gonna open it up,
just like we did when we created our own.
Now again, you'll notice,
it's CodeLite information, makefile.
You can delete this folder,
and you can delete these two files if you like.
I wouldn't delete 'em, I would just leave them in there
in case you ever wanna use CodeLite.
They're there, so you might as well keep 'em there.
So, we can't do anything yet, remember,
we need to create the dot VS code folder
with the launch JSON test, JSON and CPP properties file.
We only have to do that once per project.
So once we include this section four 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.
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 dot 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.
Alright, so what I'm gonna do is, like I said,
I'm going to create it from scratch just like we did before.
So I'm just gonna open up any one of these guys,
and select that main CPP that's important.
And then what I'm going to do
is I'm gonna 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 gonna choose.
We'll do just like before, we'll change this GCC to G++.
And we'll come down here
and we'll set the compiler standard to C++ 17.
Right there.
And that's it, I'm saving that.
And now you can see
that it's created the VS code folder,
with that CPP properties JSON file.
Pretty good.
So we're done with that,
I'm just gonna close this up.
The next thing we'll do
is we need to create the tasks dot JSON file.
So we'll come over here to terminal,
and configure default build task.
What are we using, we're using G++ right here.
And that's gonna create my tasks dot 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 dir name.
Just like that,
and I just want to add slash slash star dot CPP,
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, let me close tasks JSON,
I can select that main CPP.
And I can come up to terminal, run the build task.
And we should get a clean compile where we do,
and you can see right here where 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 EXE 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 dot EXE.
Enter your favorite number between one and 150.
Amazing, that's my favorite number too.
Just like what the source code says up here.
Okay, 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.
Right, so we're gonna 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 gonna select G++ GDB, LLDB.
We're going to select G++ again
And we're gonna get this running, when it's done,
just kill it right here with that little red box,
'cause 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 dir 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 close quote.
You're gonna get squigglies and stuff will turn red,
so make sure you don't see any of that,
everything looks 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 CPP file.
And I would click on this bug right here.
If you have any break points set down here
you can just delete them all, as I showed you before.
And now we're gonna set a break point,
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 says putting a zero in there,
that could be any value in there.
That's it.
Now if I wanna execute line eight,
which is where I'm stopped at,
I will just click this button right here and 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, or I can stop the program,
or I can do whatever I like.
That's it.
Program's 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 CodeLite or in Visual Studio Code.
Some students prefer CodeLite,
other students prefer Visual Studio Code.
And now you've got the tools to do it both ways.