Hello, everyone.
In this video.
What we'll do is we'll download and extract the source code provided in the course and we'll set it
up so that we can use it with Visual Studio code.
The source code is located in one of the last sections of the course.
Right now it's in section 22, but that could change as I add content to the course that probably becomes
section 23 and then 24 and so forth.
So the best thing is to search for a section named extra information source code and other stuff, and
in there there will be a video source code for all sections.
And when you select that this is what you're going to get, it's a bunch of links to zip files that
contain the source code for the course projects.
So what you want to do is depending on which section of the course you're in, you want to download
the zip file for that section.
So in this case, I'm going to download the source code for section four and I'm just going to click
on there and that will download a zip file, which I'm just going to save.
Okay, now that I've saved it, I'm going to go to my downloads and I'm just going to extract it.
So I'm just going to right click and extract right here.
All right.
So this is what we've got now.
You can see it's extracted it to a section four folder, and inside that section for folder are all
the projects.
So what I want to do is I want to just copy this section for folder.
Or you can cut it if you like to the desktop just so I can show you how to do it here.
So now I've just downloaded and extracted all the projects in that section into this section four folder.
So I think you know what to do.
Now, what we want to do is we want to open up this section for folder in Visual Studio code and then
set up IntelliSense, the task Jason and the launch JSON again.
So let's do that.
I'm going to close all this up because I don't need it anymore.
And what I want to do now is I want to open a folder.
So again, we'll open folder and I'm going to go to my desktop and I want to open section four.
That's the one I want.
So I'm just going to click.
Okay.
And now you'll see that Section four was opened up in Visual Studio code, which is exactly what we
want.
So also notice that there are some folders like code, light and Makefile and things like that.
Don't worry about those.
Those are things that code light needs Visual Studio.
We'll just ignore them.
But we need to configure this to work with Visual Studio, so we have to go through the same process
that we did before.
We have to do it once per major section.
A couple of ways to do this.
We could do it manually like we did before, which is what I'm going to do here, just so you can see
it one more time, or you can copy your vs code folder from an existing project into this project.
So let's just do it manually.
First thing we want to do is I want to close this, get started and I want to click on any of the let's
see this guy right here, any of the main CP files in there, any C++ source file is what we need.
And then we're going to go to view command palette and type in again C plus plus until we see edit configurations
UI.
We're going to set up the IntelliSense again.
We'll scroll down.
And make sure that we've got.
So we'll score right here to compile path and we want to be sure that we're using G plus plus right
there.
And then we're going to scroll down a little bit more to the C++ standard and we're going to choose
C++ 17.
That's it.
I'm going to control SW to save and I'm done with that.
Perfect.
Now you notice we've got our code folder here and our CPP properties are set up.
So again, I'm going to select Main CP and I'm going to come up to terminal and configure the default
build task.
I'm going to select G plus plus.
And now once I'm here, I'm going to make those same changes we made before.
I'm going to enable all warnings.
So dash wall, we are going to enable the C++ 17 standard and we're going to change the file on line
12 to file your name.
Want to copy this and I'm going to paste it right in here.
And then finally we're going to add the slash star TCP IP so that we'll compile all the files.
Now, when we do these, you notice this sometimes you'll see squiggly.
So for example, if I get rid of that comma, you'll see some squiggles show up, right?
We don't want any of those are errors and we just want to be sure that everything looks clean.
If something doesn't look clean, look at the video and make sure that you haven't missed any quote,
marks or commas and so forth.
So that's it.
I'm going to save this and I'm going to close this up.
Now what we'll do is we'll select main CPP on first program, and you can see what the first program
is doing is similar to what we did before with the favorite number.
What I want to do now is just test it out.
So I'm going to select that and I'm going to go to terminal and run the build test.
So that will build our project and you'll see builds finished successfully.
So remember the main executable was created right here, right inside that project.
So I'm going to right click on it, open an integrated terminal, and then I'm going to type dot slash
main.
What's my favorite number?
It's 34 this time.
Amazing.
That's my favorite number, too.
That's exactly what we're supposed to get.
Okay.
Perfect.
So now let's say I wanted to run Project one, I can go to Main CP there and again I can come up to
Terminal.
Run build test.
Now it's going to build project one.
You could see from the message right here.
You can see Project one is being built right there.
We've created our executive role within Project One, which I can right click open to the integrated
terminal and you can see Project one, just project one, we can run it again and now we're running
Project one.
So this is a really easy way to organize yourself and to get everything running nicely.
We're done with that.
The last step is to get the debugger working.
So what we can do now again, select one of the main CP files.
There's one.
And we come up to run and add configuration.
And select c++ gdb ltb.
And then g plus.
Plus.
We're going to get some stuff happening.
Whatever happens, just let it happen and then just kill it right here.
So I'll press that little red square.
And now what we want to do is we want to come back over to our explorer and we want to edit that launch
JSON file.
And all we really want to do is change this guy right here, this current working directory.
I want to change that to file directory name so I'm just going to copy and paste.
That's it.
I'll save.
And let's pick first program again.
So we're right here.
Let's say that this is the one we want to debug.
So what we can do is we can click on the bug.
If there are any breakpoints down here, we can clear them.
We'll add our own breakpoint.
Let's say we want to add a breakpoint right on line eight, and then we select that little green play
button right up here.
And the debugger will engage.
You can see where we're stopped on line eight and you can see my favorite numbers over here.
And we just move over.
Now, you'll notice that we're getting three, two, seven, six, seven.
What in the world is that?
I don't see that anywhere.
Well, we haven't initialized favorite number 20 thing.
So whatever display's here really is undefined and I'll talk more about that in the class.
That's really important issue with C++.
So now we can just step through the program.
Let's step through right here.
Enter your favorite number between one and 100.
So let's say I wanted to enter 56 and press enter.
Now we're on my nine and I can step over that.
Also notice my favorite number changed here and I can hover over to see that it's 56.
And when we're done, we could just finish.
And that's it.
So that's how we can get the source code provided for the course to work with Visual Studio code.
It's really pretty easy.
Once you get the hang of it, you can set up the test JSON and launch JSON files really quickly.
Or like I said, you could just copy them and paste them into the new structure that you're creating.
All right.
So that shows you how to set everything up for Linux Ubuntu.
I'll see you in the rest of the course.