1 00:00:04,820 --> 00:00:10,880 In this video, I'll show you how to use the source code provided for the course in Visual Studio code. 2 00:00:11,360 --> 00:00:16,250 So the first thing we need to do is we need to get the source code and the source code is in the course 3 00:00:16,250 --> 00:00:20,630 and you can see here in the course content and if you scroll all the way to the bottom, you'll see 4 00:00:20,630 --> 00:00:27,590 section 22, extra information source code and other stuff right here and right in there, you'll see 5 00:00:27,590 --> 00:00:29,010 source code for all sections. 6 00:00:29,010 --> 00:00:33,650 So if you click on that, you're going to see the source code that's going to be downloadable here, 7 00:00:33,860 --> 00:00:38,030 and each one of these is going to be a zip file for each section of the course. 8 00:00:38,030 --> 00:00:41,960 Now, as I'm making this video, this is in section 22. 9 00:00:41,960 --> 00:00:48,230 When you all watch this video, most likely this will be way down here, section 25 or 26 or 27 or somewhere 10 00:00:48,230 --> 00:00:54,230 down at the bottom of the content, because the new lectures that I'll put in the course will be inserted 11 00:00:54,230 --> 00:00:54,620 in here. 12 00:00:54,620 --> 00:00:59,450 So anyway, just look for extra information and then source code for all sections and you'll find it. 13 00:00:59,450 --> 00:01:02,660 And then once you do that, you can download the source code. 14 00:01:02,660 --> 00:01:09,140 So for example, I'm going to download section four right here and I'm just going to click on there 15 00:01:10,160 --> 00:01:12,200 and then I'm going to save that to my desktop. 16 00:01:12,200 --> 00:01:15,500 I've already done that and you can extract it to the desktop as well. 17 00:01:15,500 --> 00:01:19,940 So the idea is create a section for folder on my desktop. 18 00:01:19,940 --> 00:01:23,240 Now I say my desktop, you can do this anywhere you like. 19 00:01:23,600 --> 00:01:26,630 I'm just putting it on my desktop just to make it easier to show you. 20 00:01:26,630 --> 00:01:31,160 So I've already done that and if you come over here you can see my desktop. 21 00:01:31,190 --> 00:01:36,320 There is the section for folder that I unzipped and there are the contents of the folder. 22 00:01:36,350 --> 00:01:40,820 You'll notice this is a code like structure and that's okay, Visual Studio code, we'll just ignore 23 00:01:40,850 --> 00:01:41,180 that. 24 00:01:41,180 --> 00:01:47,060 But I've got one, two, three, four, five, six, seven projects inside this folder. 25 00:01:47,510 --> 00:01:49,190 So I think you know what to do. 26 00:01:49,220 --> 00:01:53,240 You go over to Visual Studio code and you open up the section for folder. 27 00:01:53,240 --> 00:01:54,950 So let's do that right now. 28 00:01:57,370 --> 00:02:04,570 So here's Visual Studio code and I'm just going to open the folder and I'm going to open up the section 29 00:02:04,570 --> 00:02:06,760 for folder on my desktop. 30 00:02:07,510 --> 00:02:13,450 So I'm just going to select that folder and it's going to open it up just like we did when we created 31 00:02:13,450 --> 00:02:13,600 our. 32 00:02:13,930 --> 00:02:17,110 Now again, you'll notice this code light information Makefile. 33 00:02:17,110 --> 00:02:20,680 You can delete this folder and you can delete these two files if you like. 34 00:02:20,800 --> 00:02:21,610 I wouldn't delete them. 35 00:02:21,610 --> 00:02:25,240 I would just leave them in there in case you ever want to use code like they're there, so you might 36 00:02:25,240 --> 00:02:26,080 as well keep them there. 37 00:02:26,590 --> 00:02:29,320 So we can't do anything yet. 38 00:02:29,320 --> 00:02:36,220 Remember, we need to create the V code folder with the launch json test, JSON and CP properties file. 39 00:02:36,370 --> 00:02:38,770 We only have to do that once per project. 40 00:02:38,770 --> 00:02:45,040 So once we include this section for folder, now we have to set that up and then after that we're good 41 00:02:45,040 --> 00:02:45,370 to go. 42 00:02:45,370 --> 00:02:50,530 We can compile and build any of these projects a couple of ways we can do this. 43 00:02:50,530 --> 00:02:53,590 We can do it the same way that we did it in the previous videos, right? 44 00:02:53,590 --> 00:02:55,390 I could just do it manually and create them. 45 00:02:55,390 --> 00:02:59,320 That's pretty easy and that's what I'm going to do now, just so that you can see it one more time, 46 00:02:59,620 --> 00:03:05,260 you can also just copy and paste that vs code folder that you've already created in that other project 47 00:03:05,260 --> 00:03:05,920 that we did. 48 00:03:05,990 --> 00:03:08,380 Just copy it right in here and it'll be good to go. 49 00:03:08,920 --> 00:03:09,190 All right. 50 00:03:09,190 --> 00:03:13,450 So what I'm going to do is, like I said, I'm going to create it from scratch, just like we did before. 51 00:03:13,450 --> 00:03:17,080 So I'm just going to open up any one of these guys and select that main. 52 00:03:17,080 --> 00:03:18,610 CP That's important. 53 00:03:19,060 --> 00:03:25,120 And then what I'm going to do is I'm going to come up here to view the command palette and select again, 54 00:03:25,120 --> 00:03:27,040 that's edit configurations UI. 55 00:03:27,040 --> 00:03:30,460 If that doesn't show up, just type C++ and it will show up somewhere in here. 56 00:03:30,460 --> 00:03:31,690 That's what I'm going to choose. 57 00:03:32,140 --> 00:03:33,490 We'll do just like before. 58 00:03:33,490 --> 00:03:40,600 We'll change this GC to G Plus Plus and we'll come down here and we'll set the compiler standard to 59 00:03:40,600 --> 00:03:44,020 C++ 17 right there. 60 00:03:44,050 --> 00:03:44,650 That's it. 61 00:03:44,650 --> 00:03:45,730 I'm saving that. 62 00:03:46,120 --> 00:03:51,820 And now you can see that it's created the V code folder with that CP properties JSON file. 63 00:03:51,820 --> 00:03:52,570 Pretty good. 64 00:03:52,870 --> 00:03:53,890 So we're done with that. 65 00:03:53,890 --> 00:03:55,180 I'm just going to close this up. 66 00:03:55,180 --> 00:04:00,640 The next thing we'll do is we need to create the task JSON file, so we'll come over here to terminal 67 00:04:00,940 --> 00:04:03,310 and configure default build task. 68 00:04:03,790 --> 00:04:05,020 What are we using? 69 00:04:05,020 --> 00:04:11,140 We're using G plus plus right here and that's going to create my test JSON file. 70 00:04:11,140 --> 00:04:16,480 What I can do here is just like we did before, I want to add my warnings. 71 00:04:16,959 --> 00:04:20,529 I want to add the C++ 17 standard. 72 00:04:23,830 --> 00:04:31,360 I want to change line 12 here, which is the file to file your name just like that. 73 00:04:31,360 --> 00:04:36,730 And I just want to add slash slash star DHCP so it compiles all the files. 74 00:04:37,300 --> 00:04:37,990 That's it. 75 00:04:37,990 --> 00:04:39,130 We're done with that. 76 00:04:39,130 --> 00:04:42,100 So at this point we can build and run a project. 77 00:04:42,100 --> 00:04:44,350 So let's run this first program right here. 78 00:04:44,350 --> 00:04:51,040 So again, I can select close test JSON, I can select that main CP and I can come up with the terminal, 79 00:04:51,220 --> 00:04:54,850 run the build test and we should get a clean compile that we do. 80 00:04:54,850 --> 00:04:58,570 And you can see right here or my mouse is that it's doing first program. 81 00:04:58,570 --> 00:05:02,830 That's that project right there, that folder and it finished successfully. 82 00:05:02,830 --> 00:05:07,720 If I want to run the XY file which was created, you can see it's created right there. 83 00:05:08,050 --> 00:05:15,490 I can right click on that, open it in the integrated terminal and just type dot slash main XY. 84 00:05:16,030 --> 00:05:19,020 Enter your favorite number between one and 150. 85 00:05:19,780 --> 00:05:20,320 Amazing. 86 00:05:20,320 --> 00:05:21,730 That's my favorite number too. 87 00:05:21,900 --> 00:05:24,010 Just like what the source code says up here. 88 00:05:25,240 --> 00:05:26,560 So that's it. 89 00:05:26,560 --> 00:05:26,980 We're done. 90 00:05:26,980 --> 00:05:30,730 We can run any of the other programs in any of the other folders the same way. 91 00:05:31,450 --> 00:05:35,350 Now, what we're going to do is we're going to set up the debugger. 92 00:05:35,620 --> 00:05:38,830 So we're going to set up our debugger so that we can debug as well. 93 00:05:38,830 --> 00:05:46,000 So what we do now is we go up to run add configuration, we're going to select g plus plus gdb lib. 94 00:05:47,060 --> 00:05:53,930 We're going to slight G plus plus again and we're going to get this running when it's done, just kill 95 00:05:53,930 --> 00:05:57,430 it right here with that little red box because we're not interested in running it right now. 96 00:05:57,440 --> 00:06:03,110 What we do want to do is we want to modify this launch JSON file and all we're doing is we're taking 97 00:06:03,110 --> 00:06:09,380 this file, your name right here, including the dollar and the curlies, just like that. 98 00:06:09,380 --> 00:06:11,780 I'm copying it and I'm pasting it into here. 99 00:06:14,870 --> 00:06:15,830 Just like that. 100 00:06:18,020 --> 00:06:18,680 And that's it. 101 00:06:18,800 --> 00:06:19,820 We're done with that. 102 00:06:20,180 --> 00:06:26,390 If you make mistakes here, let's say you forget that that close quote, you're going to get squiggles 103 00:06:26,390 --> 00:06:27,350 and stuff will turn red. 104 00:06:27,350 --> 00:06:29,000 So make sure you don't see any of that. 105 00:06:29,000 --> 00:06:31,770 Everything looks nice and nice and clean like this. 106 00:06:31,790 --> 00:06:34,670 No squiggly lines, no red errors or anything like that. 107 00:06:34,970 --> 00:06:38,270 When we're done, we can save it and I can close that up. 108 00:06:39,020 --> 00:06:40,370 And now let's say I'm here. 109 00:06:40,370 --> 00:06:46,340 And so if I want to debug this program, I would select the main CP file and I would click on this bug 110 00:06:46,340 --> 00:06:47,030 right here. 111 00:06:47,840 --> 00:06:52,160 If you have any breakpoint set down here, you can just delete them all, as I showed you before. 112 00:06:52,160 --> 00:06:55,430 And now we're going to set a breakpoint, let's say, right there. 113 00:06:56,860 --> 00:07:01,270 And once we're good to go, we just press this green arrow right here and our program will start in 114 00:07:01,270 --> 00:07:02,080 the debugger. 115 00:07:02,410 --> 00:07:06,460 You can see I've got a variable favorite number here and you can see its value is zero. 116 00:07:06,460 --> 00:07:11,080 Its value is actually undefined because I haven't defined it, but the debugger is putting a zero in 117 00:07:11,110 --> 00:07:12,940 there that could be any value in there. 118 00:07:12,940 --> 00:07:13,560 That's it. 119 00:07:13,570 --> 00:07:17,830 Now if I want to execute line eight, which is where I'm stopped at, I would just click this button 120 00:07:17,830 --> 00:07:22,840 right here, step over, and now it's asked me, enter your favorite number and it's just waiting me 121 00:07:22,840 --> 00:07:23,650 to type something in. 122 00:07:23,650 --> 00:07:26,050 I'll type in 45 and press enter. 123 00:07:26,290 --> 00:07:27,760 Now I'm at the next line. 124 00:07:27,760 --> 00:07:32,290 You can see that now favorite number is 45 and I can continue here. 125 00:07:32,290 --> 00:07:34,540 I can stop the program, I could do whatever I like. 126 00:07:34,780 --> 00:07:35,650 That's it. 127 00:07:36,100 --> 00:07:36,820 Program is finished. 128 00:07:36,820 --> 00:07:41,440 I can go back to my explorer and execute another program here. 129 00:07:41,530 --> 00:07:42,700 So there you go. 130 00:07:42,700 --> 00:07:47,410 This is how you would use the provided source code with Visual Studio code. 131 00:07:47,410 --> 00:07:52,630 So at this point, you have everything you need to be able to work in code light or in Visual Studio 132 00:07:52,630 --> 00:07:53,290 code. 133 00:07:53,290 --> 00:07:58,180 Some students prefer code light, other students prefer Visual Studio code, and now you've got the 134 00:07:58,180 --> 00:07:59,710 tools to do it both ways.