1 00:00:00,408 --> 00:00:02,893 (lively electronic music) 2 00:00:02,893 --> 00:00:05,293 (keyboard keys clack) 3 00:00:05,293 --> 00:00:06,126 Frank: In this video, 4 00:00:06,126 --> 00:00:07,260 I'll show you how to use the source code 5 00:00:07,260 --> 00:00:11,490 provided for the course in Visual Studio Code. 6 00:00:11,490 --> 00:00:12,600 So the first thing we need to do 7 00:00:12,600 --> 00:00:14,130 is we need to get the source code. 8 00:00:14,130 --> 00:00:16,230 And the source code is in the course, 9 00:00:16,230 --> 00:00:18,120 and you can see here in the course content. 10 00:00:18,120 --> 00:00:20,250 And if you scroll all the way to the bottom, 11 00:00:20,250 --> 00:00:22,860 you'll see section 22, extra information, 12 00:00:22,860 --> 00:00:25,440 source code and other stuff right here. 13 00:00:25,440 --> 00:00:28,880 And right in there, you'll see source code for all sections, 14 00:00:28,880 --> 00:00:31,800 so if you click on that, you're gonna see the source code 15 00:00:31,800 --> 00:00:34,020 that's gonna be downloadable here. 16 00:00:34,020 --> 00:00:36,450 And each one of these is going to be a ZIP file 17 00:00:36,450 --> 00:00:38,190 for each section of the course. 18 00:00:38,190 --> 00:00:42,150 Now as I'm making this video, this is in section 22, 19 00:00:42,150 --> 00:00:43,890 when you all watch this video, 20 00:00:43,890 --> 00:00:45,690 most likely this will be way down here, 21 00:00:45,690 --> 00:00:47,790 section 25 or 26 or 27 22 00:00:47,790 --> 00:00:50,880 or somewhere down at the bottom of the content. 23 00:00:50,880 --> 00:00:52,950 Because the new lectures that I'll put in the course 24 00:00:52,950 --> 00:00:54,600 will be inserted in here, 25 00:00:54,600 --> 00:00:56,910 so anyway, just look for extra information. 26 00:00:56,910 --> 00:00:59,670 And then source code for all sections, and you'll find it. 27 00:00:59,670 --> 00:01:02,670 And then once you do that, you can download the source code, 28 00:01:02,670 --> 00:01:03,600 so for example, 29 00:01:03,600 --> 00:01:06,540 I'm going to download section four, right here. 30 00:01:06,540 --> 00:01:09,213 And I'm just gonna click on there. 31 00:01:10,170 --> 00:01:12,180 And then I'm gonna save that to my desktop, 32 00:01:12,180 --> 00:01:13,050 I've already done that, 33 00:01:13,050 --> 00:01:15,660 and you can extract it to the desktop as well. 34 00:01:15,660 --> 00:01:19,950 So the idea is create a section four folder on my desktop. 35 00:01:19,950 --> 00:01:21,720 Now, I say my desktop. 36 00:01:21,720 --> 00:01:23,700 You can do this anywhere you like. 37 00:01:23,700 --> 00:01:25,050 I'm just putting it on my desktop 38 00:01:25,050 --> 00:01:26,790 just to make it easier to show you. 39 00:01:26,790 --> 00:01:28,410 So I've already done that. 40 00:01:28,410 --> 00:01:31,290 And if you come over here, you can see my desktop. 41 00:01:31,290 --> 00:01:34,590 There is the section four folder that I unzipped. 42 00:01:34,590 --> 00:01:36,390 And there are the contents of the folder. 43 00:01:36,390 --> 00:01:38,550 You'll notice this is a CodeLite structure, 44 00:01:38,550 --> 00:01:39,383 and that's okay, 45 00:01:39,383 --> 00:01:41,340 Visual Studio Code will just ignore that. 46 00:01:41,340 --> 00:01:42,173 But I've got 47 00:01:42,173 --> 00:01:45,600 one, two, three, four, five, six, seven projects 48 00:01:45,600 --> 00:01:47,610 inside this folder. 49 00:01:47,610 --> 00:01:49,200 So, I think you know what to do 50 00:01:49,200 --> 00:01:50,760 you go over to Visual Studio Code 51 00:01:50,760 --> 00:01:53,400 and you open up the section four folder. 52 00:01:53,400 --> 00:01:54,963 So let's do that right now. 53 00:01:57,450 --> 00:01:59,460 So here's Visual Studio Code. 54 00:01:59,460 --> 00:02:01,833 And I'm just going to open the folder. 55 00:02:02,880 --> 00:02:03,930 And I'm going to open up 56 00:02:03,930 --> 00:02:06,753 the section four folder on my desktop. 57 00:02:07,590 --> 00:02:10,470 So I'm just gonna select that folder. 58 00:02:10,470 --> 00:02:11,820 And it's gonna open it up, 59 00:02:11,820 --> 00:02:14,040 just like we did when we created our own. 60 00:02:14,040 --> 00:02:14,873 Now again, you'll notice, 61 00:02:14,873 --> 00:02:17,190 it's CodeLite information, makefile. 62 00:02:17,190 --> 00:02:18,480 You can delete this folder, 63 00:02:18,480 --> 00:02:20,820 and you can delete these two files if you like. 64 00:02:20,820 --> 00:02:22,500 I wouldn't delete 'em, I would just leave them in there 65 00:02:22,500 --> 00:02:24,330 in case you ever wanna use CodeLite. 66 00:02:24,330 --> 00:02:26,700 They're there, so you might as well keep 'em there. 67 00:02:26,700 --> 00:02:29,730 So, we can't do anything yet, remember, 68 00:02:29,730 --> 00:02:32,340 we need to create the dot VS code folder 69 00:02:32,340 --> 00:02:36,510 with the launch JSON test, JSON and CPP properties file. 70 00:02:36,510 --> 00:02:38,880 We only have to do that once per project. 71 00:02:38,880 --> 00:02:42,330 So once we include this section four folder, 72 00:02:42,330 --> 00:02:43,710 now we have to set that up, 73 00:02:43,710 --> 00:02:45,330 and then after that, we're good to go, 74 00:02:45,330 --> 00:02:48,453 we can compile and build any of these projects. 75 00:02:49,320 --> 00:02:51,600 Couple of ways we can do this, we can do it the same way 76 00:02:51,600 --> 00:02:53,580 that we did it in the previous videos, right, 77 00:02:53,580 --> 00:02:55,350 I could just do it manually and create them, 78 00:02:55,350 --> 00:02:56,340 that's pretty easy. 79 00:02:56,340 --> 00:02:57,570 And that's what I'm going to do now, 80 00:02:57,570 --> 00:02:59,700 just so that you can see it one more time. 81 00:02:59,700 --> 00:03:01,560 You can also just copy and paste 82 00:03:01,560 --> 00:03:04,410 that dot VS code folder that you've already created 83 00:03:04,410 --> 00:03:05,940 in that other project that we did. 84 00:03:05,940 --> 00:03:08,910 Just copy it right in here, and it'll be good to go. 85 00:03:08,910 --> 00:03:10,500 Alright, so what I'm gonna do is, like I said, 86 00:03:10,500 --> 00:03:13,590 I'm going to create it from scratch just like we did before. 87 00:03:13,590 --> 00:03:15,900 So I'm just gonna open up any one of these guys, 88 00:03:15,900 --> 00:03:19,080 and select that main CPP that's important. 89 00:03:19,080 --> 00:03:19,980 And then what I'm going to do 90 00:03:19,980 --> 00:03:22,680 is I'm gonna come up here to view the command palette. 91 00:03:23,970 --> 00:03:27,000 And select, again, that's edit configurations UI, 92 00:03:27,000 --> 00:03:29,280 if that doesn't show up, just type C++, 93 00:03:29,280 --> 00:03:30,450 and it will show up somewhere in here, 94 00:03:30,450 --> 00:03:32,220 that's what I'm gonna choose. 95 00:03:32,220 --> 00:03:36,403 We'll do just like before, we'll change this GCC to G++. 96 00:03:37,650 --> 00:03:38,580 And we'll come down here 97 00:03:38,580 --> 00:03:43,050 and we'll set the compiler standard to C++ 17. 98 00:03:43,050 --> 00:03:44,543 Right there. 99 00:03:44,543 --> 00:03:46,140 And that's it, I'm saving that. 100 00:03:46,140 --> 00:03:47,010 And now you can see 101 00:03:47,010 --> 00:03:49,230 that it's created the VS code folder, 102 00:03:49,230 --> 00:03:51,900 with that CPP properties JSON file. 103 00:03:51,900 --> 00:03:53,010 Pretty good. 104 00:03:53,010 --> 00:03:53,910 So we're done with that, 105 00:03:53,910 --> 00:03:55,230 I'm just gonna close this up. 106 00:03:55,230 --> 00:03:56,063 The next thing we'll do 107 00:03:56,063 --> 00:03:58,980 is we need to create the tasks dot JSON file. 108 00:03:58,980 --> 00:04:01,050 So we'll come over here to terminal, 109 00:04:01,050 --> 00:04:03,780 and configure default build task. 110 00:04:03,780 --> 00:04:07,353 What are we using, we're using G++ right here. 111 00:04:08,640 --> 00:04:11,160 And that's gonna create my tasks dot JSON file. 112 00:04:11,160 --> 00:04:13,380 What I can do here is just like we did before, 113 00:04:13,380 --> 00:04:16,950 I want to add my warnings. 114 00:04:16,950 --> 00:04:20,523 I want to add the C++ 17 standard. 115 00:04:23,820 --> 00:04:26,250 I want to change line 12 here, 116 00:04:26,250 --> 00:04:28,353 which is the file to file dir name. 117 00:04:30,690 --> 00:04:31,523 Just like that, 118 00:04:31,523 --> 00:04:34,620 and I just want to add slash slash star dot CPP, 119 00:04:34,620 --> 00:04:37,290 so it compiles all the files. 120 00:04:37,290 --> 00:04:39,300 That's it, we're done with that. 121 00:04:39,300 --> 00:04:42,090 So at this point we can build and run a project, 122 00:04:42,090 --> 00:04:44,520 so let's run this first program right here. 123 00:04:44,520 --> 00:04:47,160 So again, I can select, let me close tasks JSON, 124 00:04:47,160 --> 00:04:49,560 I can select that main CPP. 125 00:04:49,560 --> 00:04:52,980 And I can come up to terminal, run the build task. 126 00:04:52,980 --> 00:04:54,810 And we should get a clean compile where we do, 127 00:04:54,810 --> 00:04:57,060 and you can see right here where my mouse is, 128 00:04:57,060 --> 00:04:58,560 that it's doing first program, 129 00:04:58,560 --> 00:05:01,140 that's that project right there, that folder. 130 00:05:01,140 --> 00:05:02,910 And it finished successfully. 131 00:05:02,910 --> 00:05:05,820 If I want to run the EXE file which was created 132 00:05:05,820 --> 00:05:08,040 you can see it's created right there. 133 00:05:08,040 --> 00:05:09,630 I can right click on that, 134 00:05:09,630 --> 00:05:11,640 open it in the integrated terminal. 135 00:05:11,640 --> 00:05:15,063 And just type dot slash main dot EXE. 136 00:05:16,170 --> 00:05:19,770 Enter your favorite number between one and 150. 137 00:05:19,770 --> 00:05:21,930 Amazing, that's my favorite number too. 138 00:05:21,930 --> 00:05:24,900 Just like what the source code says up here. 139 00:05:24,900 --> 00:05:26,970 Okay, so, that's it, we're done, 140 00:05:26,970 --> 00:05:28,680 we can run any of the other programs 141 00:05:28,680 --> 00:05:31,500 in any of the other folders the same way. 142 00:05:31,500 --> 00:05:33,030 Now what we're going to do is, 143 00:05:33,030 --> 00:05:35,400 we're going to set up the debugger. 144 00:05:35,400 --> 00:05:37,050 Right, so we're gonna set up our debugger 145 00:05:37,050 --> 00:05:38,910 so that we can debug as well. 146 00:05:38,910 --> 00:05:42,840 So what we do now is we go up to Run, Add Configuration. 147 00:05:42,840 --> 00:05:45,963 We're gonna select G++ GDB, LLDB. 148 00:05:47,070 --> 00:05:49,000 We're going to select G++ again 149 00:05:50,280 --> 00:05:53,430 And we're gonna get this running, when it's done, 150 00:05:53,430 --> 00:05:55,350 just kill it right here with that little red box, 151 00:05:55,350 --> 00:05:57,510 'cause we're not interested in running it right now. 152 00:05:57,510 --> 00:05:58,410 What we do want to do 153 00:05:58,410 --> 00:06:01,410 is we want to modify this launch JSON file. 154 00:06:01,410 --> 00:06:02,580 And all we're doing is, 155 00:06:02,580 --> 00:06:05,940 we're taking this file dir name, right here. 156 00:06:05,940 --> 00:06:08,640 Including the dollar and the curlies. 157 00:06:08,640 --> 00:06:11,793 Just like that, I'm copying it and I'm pasting it into here. 158 00:06:14,880 --> 00:06:15,843 Just like that. 159 00:06:18,000 --> 00:06:20,250 And that's it, we're done with that. 160 00:06:20,250 --> 00:06:21,690 If you make mistakes here, 161 00:06:21,690 --> 00:06:25,200 let's say you forget that close quote. 162 00:06:25,200 --> 00:06:27,330 You're gonna get squigglies and stuff will turn red, 163 00:06:27,330 --> 00:06:29,010 so make sure you don't see any of that, 164 00:06:29,010 --> 00:06:31,740 everything looks nice and clean like this, 165 00:06:31,740 --> 00:06:35,040 no squiggly lines, no red errors or anything like that. 166 00:06:35,040 --> 00:06:38,313 When we're done, we can save it, and I can close that up. 167 00:06:39,180 --> 00:06:40,350 And now let's say I'm here, 168 00:06:40,350 --> 00:06:42,210 and so if I want to debug this program, 169 00:06:42,210 --> 00:06:45,120 I would select the main CPP file. 170 00:06:45,120 --> 00:06:47,850 And I would click on this bug right here. 171 00:06:47,850 --> 00:06:49,740 If you have any break points set down here 172 00:06:49,740 --> 00:06:52,350 you can just delete them all, as I showed you before. 173 00:06:52,350 --> 00:06:53,700 And now we're gonna set a break point, 174 00:06:53,700 --> 00:06:55,323 let's say right there. 175 00:06:56,880 --> 00:06:57,990 And once we're good to go, 176 00:06:57,990 --> 00:06:59,880 we just press this green arrow right here, 177 00:06:59,880 --> 00:07:02,490 and our program will start in the debugger. 178 00:07:02,490 --> 00:07:04,950 You can see I've got a variable favorite number here, 179 00:07:04,950 --> 00:07:06,450 and you can see its value is zero, 180 00:07:06,450 --> 00:07:08,010 its value is actually undefined, 181 00:07:08,010 --> 00:07:09,420 because I haven't defined it. 182 00:07:09,420 --> 00:07:11,340 But the debugger says putting a zero in there, 183 00:07:11,340 --> 00:07:12,960 that could be any value in there. 184 00:07:12,960 --> 00:07:13,793 That's it. 185 00:07:13,793 --> 00:07:15,270 Now if I wanna execute line eight, 186 00:07:15,270 --> 00:07:16,500 which is where I'm stopped at, 187 00:07:16,500 --> 00:07:19,250 I will just click this button right here and step over. 188 00:07:20,160 --> 00:07:22,460 And now it's asked me, enter your favorite number, 189 00:07:22,460 --> 00:07:23,640 and it's just waiting me to type something in, 190 00:07:23,640 --> 00:07:26,340 I'll type in 45, and press Enter. 191 00:07:26,340 --> 00:07:27,750 Now I'm at the next line, 192 00:07:27,750 --> 00:07:30,960 you can see that now favorite number is 45. 193 00:07:30,960 --> 00:07:33,200 And I can continue here, or I can stop the program, 194 00:07:33,200 --> 00:07:34,860 or I can do whatever I like. 195 00:07:34,860 --> 00:07:36,090 That's it. 196 00:07:36,090 --> 00:07:39,090 Program's finished, I can go back to my explorer, 197 00:07:39,090 --> 00:07:41,670 and execute another program here. 198 00:07:41,670 --> 00:07:42,750 So there you go. 199 00:07:42,750 --> 00:07:45,900 This is how you would use the provided source code 200 00:07:45,900 --> 00:07:47,490 with Visual Studio Code. 201 00:07:47,490 --> 00:07:49,260 So at this point, you have everything you need 202 00:07:49,260 --> 00:07:53,430 to be able to work in CodeLite or in Visual Studio Code. 203 00:07:53,430 --> 00:07:54,840 Some students prefer CodeLite, 204 00:07:54,840 --> 00:07:57,240 other students prefer Visual Studio Code. 205 00:07:57,240 --> 00:07:59,640 And now you've got the tools to do it both ways.