1 00:00:00,033 --> 00:00:02,616 (upbeat music) 2 00:00:05,370 --> 00:00:06,689 -: Welcome back, in this video, 3 00:00:06,689 --> 00:00:10,110 what I'm going to do is I'm going to build 4 00:00:10,110 --> 00:00:15,090 and run a sample C++ program using Visual Studio Code. 5 00:00:15,090 --> 00:00:17,850 First thing we need to do is we need to create a folder. 6 00:00:17,850 --> 00:00:21,060 That folder is going to hold our projects. 7 00:00:21,060 --> 00:00:22,470 We're gonna have more than one project, 8 00:00:22,470 --> 00:00:24,660 which makes life a lot simpler. 9 00:00:24,660 --> 00:00:27,990 Most of the ways that you see Visual Studio Code set up 10 00:00:27,990 --> 00:00:31,650 on the web is basically just one project, 11 00:00:31,650 --> 00:00:33,510 and one project at a time. 12 00:00:33,510 --> 00:00:35,820 And that's okay, but it becomes really tedious 13 00:00:35,820 --> 00:00:37,530 for a course like this where we've got a lot 14 00:00:37,530 --> 00:00:40,170 of little projects and we're learning a lot as we go. 15 00:00:40,170 --> 00:00:42,840 It's much more efficient just to create one folder 16 00:00:42,840 --> 00:00:44,280 that holds a bunch of projects 17 00:00:44,280 --> 00:00:45,930 for each section of the course. 18 00:00:45,930 --> 00:00:47,498 Okay, so first thing we're gonna do 19 00:00:47,498 --> 00:00:48,750 is we're gonna create that folder. 20 00:00:48,750 --> 00:00:49,650 Then what we're gonna do 21 00:00:49,650 --> 00:00:52,290 is we're gonna write a really small C++ program 22 00:00:52,290 --> 00:00:54,510 that we'll be able to test easily. 23 00:00:54,510 --> 00:00:56,460 Then we'll configure Visual Studio Code 24 00:00:56,460 --> 00:00:57,840 to build and run that. 25 00:00:57,840 --> 00:01:01,680 Okay, so first order of business is to create that folder. 26 00:01:01,680 --> 00:01:04,680 Now, I don't create the folder within Visual Studio Code, 27 00:01:04,680 --> 00:01:06,570 I just do it right in the file system. 28 00:01:06,570 --> 00:01:08,940 So I'm just gonna minimize this for a minute, 29 00:01:08,940 --> 00:01:10,110 and I'm gonna go to my desktop 30 00:01:10,110 --> 00:01:11,860 and I'm gonna create a folder here. 31 00:01:13,140 --> 00:01:15,813 And I'm just gonna call this SectionX, let's say. 32 00:01:16,800 --> 00:01:18,930 Now you can organize your folders however you like. 33 00:01:18,930 --> 00:01:21,750 Section 1, Section 2, Section 3 of the course. 34 00:01:21,750 --> 00:01:23,040 SectionX is what I'm gonna use 35 00:01:23,040 --> 00:01:25,590 to represent any section that you might be working on. 36 00:01:25,590 --> 00:01:27,480 So that's it, it's just an empty folder, 37 00:01:27,480 --> 00:01:28,590 there's nothing in it. 38 00:01:28,590 --> 00:01:31,230 We're gonna create sub-folders within it. 39 00:01:31,230 --> 00:01:34,380 Each sub-folder will be a different project, 40 00:01:34,380 --> 00:01:36,960 but we'll do that part in Visual Studio Code. 41 00:01:36,960 --> 00:01:39,123 So let me come back to Visual Studio Code. 42 00:01:40,620 --> 00:01:42,990 And now what I wanna do is I want to open the folder. 43 00:01:42,990 --> 00:01:44,460 I can do it right here. 44 00:01:44,460 --> 00:01:46,980 I can also use these command keys 45 00:01:46,980 --> 00:01:48,270 and I can also come up to here 46 00:01:48,270 --> 00:01:50,850 where it says File, Open Folder. 47 00:01:50,850 --> 00:01:52,680 I'll select the desktop. 48 00:01:52,680 --> 00:01:54,930 So now what I'll do is I'll select the desktop, 49 00:01:54,930 --> 00:01:57,390 and I'll select SectionX, 50 00:01:57,390 --> 00:01:59,970 and I'll select the folder down here. 51 00:01:59,970 --> 00:02:03,390 And now what happens is Visual Studio Code has opened 52 00:02:03,390 --> 00:02:05,520 up the SectionX folder. 53 00:02:05,520 --> 00:02:08,037 There's nothing in it, it's just an empty folder right now. 54 00:02:08,037 --> 00:02:10,800 And we can create new files and open files and so forth. 55 00:02:10,800 --> 00:02:12,150 Now what I'm gonna do is I'm gonna close this 56 00:02:12,150 --> 00:02:15,210 down right here, just so we don't clutter anything up. 57 00:02:15,210 --> 00:02:16,130 And the first thing I'm gonna do 58 00:02:16,130 --> 00:02:17,970 is I'm gonna create a sub folder 59 00:02:17,970 --> 00:02:20,550 within this SectionX folder. 60 00:02:20,550 --> 00:02:23,520 And we can do that by clicking that icon right there, 61 00:02:23,520 --> 00:02:26,130 New Folder, this creates a new file, 62 00:02:26,130 --> 00:02:27,240 this creates a new folder. 63 00:02:27,240 --> 00:02:28,620 So that's what we're going to do, 64 00:02:28,620 --> 00:02:31,083 and I'm gonna call it Project 1. 65 00:02:32,280 --> 00:02:34,500 We can create multiple projects, 66 00:02:34,500 --> 00:02:36,240 and I'll show you how to do that in a little bit. 67 00:02:36,240 --> 00:02:37,830 And then within Project 1, 68 00:02:37,830 --> 00:02:40,230 so we wanna be sure that Project 1 is selected, 69 00:02:40,230 --> 00:02:41,577 we're gonna create a new file, 70 00:02:41,577 --> 00:02:45,060 and that new file is main.cpp. 71 00:02:45,060 --> 00:02:47,340 That's our main C++ program. 72 00:02:47,340 --> 00:02:49,710 This is that little test program that we're going to write. 73 00:02:49,710 --> 00:02:51,600 So I could just select that, 74 00:02:51,600 --> 00:02:53,250 and we're gonna get this message down here, 75 00:02:53,250 --> 00:02:55,800 do you want to use the insider's version. 76 00:02:55,800 --> 00:02:59,850 That allows you to use new features in Visual Studio Code 77 00:02:59,850 --> 00:03:01,800 that maybe aren't ready for prime time yet, 78 00:03:01,800 --> 00:03:02,880 they're still being worked out, 79 00:03:02,880 --> 00:03:04,680 release candidates and so forth. 80 00:03:04,680 --> 00:03:08,550 I'm just gonna say no, I wanna use the stable version. 81 00:03:08,550 --> 00:03:09,510 And now what we're gonna do here 82 00:03:09,510 --> 00:03:12,570 is we're gonna write a really simple C++ program 83 00:03:12,570 --> 00:03:14,400 so that we can configure it to run. 84 00:03:14,400 --> 00:03:16,050 So lemme show you how to do that. 85 00:03:16,920 --> 00:03:19,320 A lot of this you won't know yet, 86 00:03:19,320 --> 00:03:21,600 especially if you're just starting out the course. 87 00:03:21,600 --> 00:03:24,840 But just type along, follow along. 88 00:03:24,840 --> 00:03:27,510 And all this will be explained during the course. 89 00:03:27,510 --> 00:03:29,797 So I'm gonna say using namespace std. 90 00:03:33,240 --> 00:03:35,520 And now we're gonna create an int main, 91 00:03:35,520 --> 00:03:37,290 that's our main function. 92 00:03:37,290 --> 00:03:38,430 And then all we're gonna say in here 93 00:03:38,430 --> 00:03:41,943 is cout, hello from Project 1, 94 00:03:42,870 --> 00:03:45,210 just so we know that if that displays, 95 00:03:45,210 --> 00:03:46,893 our program is running correctly. 96 00:03:49,110 --> 00:03:51,780 Alright, as I said, all this will be explained, 97 00:03:51,780 --> 00:03:53,970 so don't worry about it if you don't understand the syntax, 98 00:03:53,970 --> 00:03:55,950 that's perfectly normal. 99 00:03:55,950 --> 00:03:59,430 Okay, now, so we've got this program that we want to run, 100 00:03:59,430 --> 00:04:01,830 and it is in Project 1 folder, 101 00:04:01,830 --> 00:04:06,300 which is in the SectionX root folder, perfect. 102 00:04:06,300 --> 00:04:09,690 It's very important now that we always select the file 103 00:04:09,690 --> 00:04:10,523 that we want to run. 104 00:04:10,523 --> 00:04:15,330 We may have multiple projects with multiple main.cpp files. 105 00:04:15,330 --> 00:04:18,720 Visual Studio Code runs the active one, 106 00:04:18,720 --> 00:04:20,190 which is the one that's selected. 107 00:04:20,190 --> 00:04:22,200 So it's really important that we select it. 108 00:04:22,200 --> 00:04:25,380 Now before we run it, we need to do some configuration. 109 00:04:25,380 --> 00:04:28,050 So we can come up here to View, Command Palette, 110 00:04:28,050 --> 00:04:30,510 or press Control + Shift + P. 111 00:04:30,510 --> 00:04:31,350 And what we're gonna do here 112 00:04:31,350 --> 00:04:33,390 is we're just gonna type C++. 113 00:04:33,390 --> 00:04:34,860 And somewhere in here you're gonna get 114 00:04:34,860 --> 00:04:37,350 an Edit Configurations UI. 115 00:04:37,350 --> 00:04:38,820 That's what we need to do. 116 00:04:38,820 --> 00:04:40,590 That's going to configure 117 00:04:40,590 --> 00:04:43,200 the Visual Studio Code IntelliSense, 118 00:04:43,200 --> 00:04:45,840 which is a real nice feature, as we type our code, 119 00:04:45,840 --> 00:04:48,120 it's gonna try to help us figure out, you know, 120 00:04:48,120 --> 00:04:49,890 what errors we might have and so forth. 121 00:04:49,890 --> 00:04:52,860 So I'll show you how to do that, we just select that, 122 00:04:52,860 --> 00:04:54,240 and we're gonna come right into here, 123 00:04:54,240 --> 00:04:56,610 IntelliSense configurations. 124 00:04:56,610 --> 00:04:59,460 And most of these we're not gonna mess with. 125 00:04:59,460 --> 00:05:01,350 This compiler right here, 126 00:05:01,350 --> 00:05:03,030 notice that it's already figured out 127 00:05:03,030 --> 00:05:06,060 that I'm using the mingw64 compiler. 128 00:05:06,060 --> 00:05:08,460 That gcc though is not the one we want. 129 00:05:08,460 --> 00:05:12,000 We want the g++, that guy right there. 130 00:05:12,000 --> 00:05:14,160 We may have other compilers on the system as well, 131 00:05:14,160 --> 00:05:16,800 but this is the one I want to use, mingw. 132 00:05:16,800 --> 00:05:20,430 So make sure that that's g++, not gcc, 133 00:05:20,430 --> 00:05:22,830 gcc is the C compiler. 134 00:05:22,830 --> 00:05:25,620 So I'm gonna scroll down just a little bit more. 135 00:05:25,620 --> 00:05:29,580 And then right here, for the C++ standard, 136 00:05:29,580 --> 00:05:31,710 you can use 14 or 17. 137 00:05:31,710 --> 00:05:35,160 I'm just gonna use c++17. 138 00:05:35,160 --> 00:05:37,950 That tells IntelliSense to use that standard 139 00:05:37,950 --> 00:05:39,920 when it's looking through the code, that's it. 140 00:05:39,920 --> 00:05:42,813 So you can press Ctrl + S to Save, 141 00:05:44,070 --> 00:05:46,770 and our IntelliSense now is configured. 142 00:05:46,770 --> 00:05:49,170 You'll notice what happened over here on the left side, 143 00:05:49,170 --> 00:05:54,030 A .vs code folder was created, and if you expand that, 144 00:05:54,030 --> 00:05:57,450 it created a c_cpp.properties.json file. 145 00:05:57,450 --> 00:06:00,150 That's a configuration file that has all that stuff 146 00:06:00,150 --> 00:06:01,500 that we just set. 147 00:06:01,500 --> 00:06:03,870 Okay, so we're almost done, not quite. 148 00:06:03,870 --> 00:06:08,730 What we need to do now is we need to configure a build task, 149 00:06:08,730 --> 00:06:10,320 and I'll show you how that works. 150 00:06:10,320 --> 00:06:12,600 You can come up here to Terminal, 151 00:06:12,600 --> 00:06:16,140 and Configure Default Build Task right here. 152 00:06:16,140 --> 00:06:17,640 Select that. 153 00:06:17,640 --> 00:06:20,157 Now it's gonna ask us what compiler do you want to use? 154 00:06:20,157 --> 00:06:22,140 And we may get a lot of different compilers, 155 00:06:22,140 --> 00:06:24,540 depending on what's installed on your system. 156 00:06:24,540 --> 00:06:28,710 It's important that you use mingw64 g++. 157 00:06:28,710 --> 00:06:30,660 This guy right here, don't use this, 158 00:06:30,660 --> 00:06:32,220 that's a pre-processor. 159 00:06:32,220 --> 00:06:34,440 Don't use this, that's the C compiler. 160 00:06:34,440 --> 00:06:38,820 Make sure we're using some kind of g++ or c++, 161 00:06:38,820 --> 00:06:39,653 something in there. 162 00:06:39,653 --> 00:06:42,570 If you're using mingw64, this is what it's gonna be. 163 00:06:42,570 --> 00:06:44,190 It might be installed in a different place, 164 00:06:44,190 --> 00:06:47,520 but you're gonna see the mingw64 and the g++. 165 00:06:47,520 --> 00:06:49,410 That's what I'm gonna select. 166 00:06:49,410 --> 00:06:51,390 Okay, so notice now what happened, 167 00:06:51,390 --> 00:06:55,440 it created a tasks.json configuration file. 168 00:06:55,440 --> 00:06:58,200 So we need to make a few changes here. 169 00:06:58,200 --> 00:07:00,240 Right here on line nine- 170 00:07:00,240 --> 00:07:01,500 right after line nine, 171 00:07:01,500 --> 00:07:04,920 I'm gonna add a few command line switches. 172 00:07:04,920 --> 00:07:09,540 One is -W, all, lowercase, 173 00:07:09,540 --> 00:07:13,890 followed by a comma, that tells the C++ compiler 174 00:07:13,890 --> 00:07:17,130 to generate warnings, all warnings that it can. 175 00:07:17,130 --> 00:07:19,560 Then I'm gonna press Enter, and again, 176 00:07:19,560 --> 00:07:20,700 I'm gonna use some quote marks, 177 00:07:20,700 --> 00:07:25,700 and I'm gonna say -std=c++17, 178 00:07:25,860 --> 00:07:27,750 and a comma at the end, 179 00:07:27,750 --> 00:07:32,100 that tells the build to use the c++17 compiler. 180 00:07:32,100 --> 00:07:34,230 Now there's one more thing we need to do 181 00:07:34,230 --> 00:07:37,680 right here where it says file directory name, 182 00:07:37,680 --> 00:07:40,500 we want to copy that, and put it right in here. 183 00:07:40,500 --> 00:07:44,550 So we're gonna replace file with file directory name. 184 00:07:44,550 --> 00:07:46,470 Okay, so I'm just gonna paste it right in there 185 00:07:46,470 --> 00:07:48,630 so I don't have any typos. 186 00:07:48,630 --> 00:07:50,700 And then, right at the end of that, 187 00:07:50,700 --> 00:07:52,290 right between the curly and the quote, 188 00:07:52,290 --> 00:07:55,783 I'm just gonna do a \\*.cpp. 189 00:07:58,140 --> 00:08:02,250 And that tells the build system to compile all the C++ files 190 00:08:02,250 --> 00:08:04,350 that it sees in the project. 191 00:08:04,350 --> 00:08:06,720 One of the problems with Visual Studio Code 192 00:08:06,720 --> 00:08:08,160 as it comes configured, 193 00:08:08,160 --> 00:08:11,130 it only builds the one single C++ file. 194 00:08:11,130 --> 00:08:13,050 So when students write larger programs 195 00:08:13,050 --> 00:08:15,930 that have multiple C++ files, they have errors, 196 00:08:15,930 --> 00:08:18,630 because they can't build multiple C++ files. 197 00:08:18,630 --> 00:08:21,060 So that's it, that takes care of this. 198 00:08:21,060 --> 00:08:25,380 I'm going to save this and I'm going to get outta here. 199 00:08:25,380 --> 00:08:27,300 So now I'm right back to here. 200 00:08:27,300 --> 00:08:29,100 So what I want to do next is I want 201 00:08:29,100 --> 00:08:32,520 to build this program, that means compile it then link it. 202 00:08:32,520 --> 00:08:34,530 So I'm gonna come up to Terminal, 203 00:08:34,530 --> 00:08:38,940 and I'm gonna say Run Build Task, 204 00:08:38,940 --> 00:08:40,500 Control + Shift + B. 205 00:08:40,500 --> 00:08:43,440 Now when I do that, we'll get some stuff going on down here, 206 00:08:43,440 --> 00:08:47,340 and notice it says build finished successfully. 207 00:08:47,340 --> 00:08:50,040 And it'll also see that Wall 208 00:08:50,040 --> 00:08:52,440 and the standard c++17. 209 00:08:52,440 --> 00:08:54,420 All those compiler flags that we put 210 00:08:54,420 --> 00:08:56,760 in the tests.json file, 211 00:08:56,760 --> 00:08:58,680 this is where they're being used. 212 00:08:58,680 --> 00:09:01,170 There's the *cpp that we changed. 213 00:09:01,170 --> 00:09:03,120 So basically it's compiling everything 214 00:09:03,120 --> 00:09:05,190 in that Project 1 folder, 215 00:09:05,190 --> 00:09:07,473 and creating a file called main.exe. 216 00:09:08,490 --> 00:09:10,127 That's our executable file, 217 00:09:10,127 --> 00:09:11,190 that's the one we can run. 218 00:09:11,190 --> 00:09:13,620 And you can see it right over here. 219 00:09:13,620 --> 00:09:14,787 There it is. 220 00:09:14,787 --> 00:09:17,490 Now what we can do is we can run that executable. 221 00:09:17,490 --> 00:09:20,400 So I'm going to right click on that executable, 222 00:09:20,400 --> 00:09:22,563 and open it in the integrated terminal. 223 00:09:24,180 --> 00:09:27,210 And you can see that it's opened up a command prompt 224 00:09:27,210 --> 00:09:29,250 right in that Project 1 directory. 225 00:09:29,250 --> 00:09:32,040 And that's exactly where main.exe is. 226 00:09:32,040 --> 00:09:36,510 So if I type ls, that just gives us a file listing, 227 00:09:36,510 --> 00:09:38,730 and we can see that we've got our main.cpp 228 00:09:38,730 --> 00:09:39,993 and our main.exe. 229 00:09:40,890 --> 00:09:42,480 So what we want to do now is we want 230 00:09:42,480 --> 00:09:44,880 to run the main.exe program 231 00:09:44,880 --> 00:09:49,880 so we can do a .\main.exe and press Enter. 232 00:09:50,490 --> 00:09:52,797 And there it is, "Hello from Project 1." 233 00:09:54,300 --> 00:09:55,530 Simple as that. 234 00:09:55,530 --> 00:09:56,580 So notice what we did, 235 00:09:56,580 --> 00:09:58,890 we built the program, and by the way, 236 00:09:58,890 --> 00:10:01,140 these configurations that we've done are, 237 00:10:01,140 --> 00:10:03,180 we're done with that, we don't have to do that again. 238 00:10:03,180 --> 00:10:04,560 We can create new projects, 239 00:10:04,560 --> 00:10:07,740 we can create new cpp files within those projects. 240 00:10:07,740 --> 00:10:10,680 These configurations will apply to all of them. 241 00:10:10,680 --> 00:10:12,210 So lemme show you how to do that. 242 00:10:12,210 --> 00:10:13,170 Let me close this down, 243 00:10:13,170 --> 00:10:15,900 and let's create another project, Project 2. 244 00:10:15,900 --> 00:10:20,100 So if I click over here and I select that guy, 245 00:10:20,100 --> 00:10:22,740 now it's gonna create the folder within Project 1. 246 00:10:22,740 --> 00:10:23,610 That's not what I want. 247 00:10:23,610 --> 00:10:27,750 I want Project 2 to be at the same level as Project 1. 248 00:10:27,750 --> 00:10:29,730 And at first you're thinking, how do I do that? 249 00:10:29,730 --> 00:10:31,590 I know, I remember I couldn't figure it out. 250 00:10:31,590 --> 00:10:33,480 The way you do it is, and when you press this, 251 00:10:33,480 --> 00:10:36,360 you click main.cpp for example, and you press escape, 252 00:10:36,360 --> 00:10:39,120 and notice this blue box that just showed up. 253 00:10:39,120 --> 00:10:40,230 It's not really intuitive 254 00:10:40,230 --> 00:10:41,580 that you need to press escape there, 255 00:10:41,580 --> 00:10:42,900 but that's what works. 256 00:10:42,900 --> 00:10:46,380 Now we can come over here and create a new folder, 257 00:10:46,380 --> 00:10:48,080 and we're gonna call it Project 2. 258 00:10:50,029 --> 00:10:51,387 And notice now that Project 1 259 00:10:51,387 --> 00:10:53,490 and Project 2 are at the same level, 260 00:10:53,490 --> 00:10:54,720 which is what we want. 261 00:10:54,720 --> 00:10:57,870 So I'm just gonna copy Project 1. 262 00:10:57,870 --> 00:10:59,800 So I'm just gonna do a Copy and Paste 263 00:11:00,660 --> 00:11:03,300 and I'm gonna come over here to Project 2, 264 00:11:03,300 --> 00:11:07,470 and I'm gonna create a main.cpp, just like we did before. 265 00:11:07,470 --> 00:11:08,490 And I'm just gonna copy that 266 00:11:08,490 --> 00:11:10,530 so I don't have to type it all in again. 267 00:11:10,530 --> 00:11:13,137 I'm just gonna say, "Hello from Project 2." 268 00:11:15,750 --> 00:11:17,550 That's it, so now what do we wanna do? 269 00:11:17,550 --> 00:11:19,620 We wanna run Project 2. 270 00:11:19,620 --> 00:11:22,470 So remember it has to be the active file. 271 00:11:22,470 --> 00:11:26,430 So you wanna make sure that you are clicking here, right? 272 00:11:26,430 --> 00:11:28,800 And then what we're gonna do is we're gonna go to Terminal, 273 00:11:28,800 --> 00:11:31,290 Control + Shift + B, or Run Build Task. 274 00:11:31,290 --> 00:11:33,360 I tend to just do Control + Shift + B, 275 00:11:33,360 --> 00:11:34,710 but I'll do it this way here, 276 00:11:34,710 --> 00:11:36,780 so you can see exactly what I'm doing. 277 00:11:36,780 --> 00:11:38,370 So Run Build Task, 278 00:11:38,370 --> 00:11:41,760 it is going to compile and build Project 2. 279 00:11:41,760 --> 00:11:44,700 You can see right over here where my mouse is, 280 00:11:44,700 --> 00:11:47,940 and it created another main.exe file. 281 00:11:47,940 --> 00:11:50,277 If I wanna run that, I can right click on it,. 282 00:11:51,510 --> 00:11:56,510 Open in the Integrated Terminal, and do a .\main.exe, 283 00:11:57,397 --> 00:11:59,730 "Hello from Project 2." 284 00:11:59,730 --> 00:12:04,080 So this is how we can create as many projects as we want. 285 00:12:04,080 --> 00:12:06,390 It's really easy and it's really convenient, 286 00:12:06,390 --> 00:12:07,950 because sometimes when we're learning, 287 00:12:07,950 --> 00:12:09,780 we're trying different projects out. 288 00:12:09,780 --> 00:12:11,310 So that's pretty much it. 289 00:12:11,310 --> 00:12:12,990 We can also, when we run the program, 290 00:12:12,990 --> 00:12:14,490 we can grab input from the user. 291 00:12:14,490 --> 00:12:17,820 So if I wanted to change this Project 2 right here, 292 00:12:17,820 --> 00:12:20,523 I could always say, let's see, 293 00:12:21,510 --> 00:12:26,510 int num, and then we're gonna say something like, 294 00:12:28,920 --> 00:12:33,093 cout Enter your favorite number, 295 00:12:38,190 --> 00:12:41,973 and then we'll read that from the user into num. 296 00:12:44,040 --> 00:12:49,040 And then we'll just display cout "Your favorite number is," 297 00:12:51,540 --> 00:12:53,040 what they just entered, right? 298 00:12:54,630 --> 00:12:57,273 Num, and we'll put a new line at the end. 299 00:12:58,320 --> 00:13:01,620 So this program now has input and output. 300 00:13:01,620 --> 00:13:03,450 And remember, I can't just run it again, 301 00:13:03,450 --> 00:13:04,530 because I have to rebuild it. 302 00:13:04,530 --> 00:13:08,340 If I run main.exe, let me show you how that works. 303 00:13:08,340 --> 00:13:09,483 It'll just, 304 00:13:11,323 --> 00:13:12,510 it'll run the previous one, right, 305 00:13:12,510 --> 00:13:13,860 'cause I haven't built it again. 306 00:13:13,860 --> 00:13:16,230 So I have to come up to Terminal, 307 00:13:16,230 --> 00:13:19,680 Build Active, there we go. 308 00:13:19,680 --> 00:13:21,540 Now I can run this main.exe, 309 00:13:21,540 --> 00:13:24,573 because it's been rebuilt, and I can run that. 310 00:13:27,630 --> 00:13:29,190 And it's gonna say "Enter your favorite number." 311 00:13:29,190 --> 00:13:30,490 and I'm gonna enter a 100. 312 00:13:31,417 --> 00:13:33,540 "Your favorite number is 100." okay? 313 00:13:33,540 --> 00:13:34,920 And I could have put a space right in here 314 00:13:34,920 --> 00:13:36,570 or something like that and a colon, 315 00:13:36,570 --> 00:13:39,210 just to prompt a user in a little prettier way. 316 00:13:39,210 --> 00:13:41,430 So that's it, this is how we can build 317 00:13:41,430 --> 00:13:44,610 and run our C++ programs. 318 00:13:44,610 --> 00:13:45,840 In the next video, what we'll do 319 00:13:45,840 --> 00:13:48,060 is we'll create one more configuration file 320 00:13:48,060 --> 00:13:50,460 called launch.json. 321 00:13:50,460 --> 00:13:52,080 And what that's gonna do is it's gonna allow us 322 00:13:52,080 --> 00:13:55,170 to use the debugger so that we can walk through code 323 00:13:55,170 --> 00:13:58,560 and debug code, especially code that's really tricky 324 00:13:58,560 --> 00:13:59,550 or it's giving us problems 325 00:13:59,550 --> 00:14:01,140 where we're trying to find an error. 326 00:14:01,140 --> 00:14:03,473 And I'll show you how to do that in the next video.