From the course: Level Up: C++

Using the exercise files on GitHub - C++ Tutorial

From the course: Level Up: C++

Using the exercise files on GitHub

- [Instructor] Let me show you how to find the exercise files in the GitHub repository. This is a flat branch repository, so you can find the code related to each challenge under the source folder which contains one folder per challenge. Each of these folders has two sub-folders, challenge and solution. The challenge folder contains some code you may want to use as a starting point. Don't worry, this code doesn't solve the challenge for you. The solution folder contains one solution I decided to showcase in the course, but keep in mind that there are infinite solutions to every problem. If you want to download the code and use it in your favorite IDE, you may do so by clicking on the green code button. Under the local tab, you can clone the repository or download the code in a zip file. However, I want to invite you to try solving the challenges using GitHub code spaces, a cloud-based IDE you may use with this course. Let me start a code space from GitHub and show you how everything is already set up for you to start coding. All you need to do is click on the code button and under the code spaces tab you can start a new code space or open an existing one. Setting up the code space may take a while. Once started, you will see a cloud version of Visual Studio Code with your repository as an open folder so you can browse to find any of your files. All the challenges in this course are console applications which means that they run on the text terminal. Let me show you the startup code for challenge number 12 which is about calculating your age in days. All the startup code in the challenge folders compiles and runs and Visual Studio is already set up for you to compile, run, and debug your code by simply pressing F5 or the debug button at the top right. The first time you run a program in a code space the debug console will pop up. You may safely click on the terminal tab to see your application. Remember, you only have to do this once, the first time. The startup program is asking for three numbers, a month, a day, and a year. Then it claims that I am zero years old. That's obviously wrong because the solution isn't implemented yet. As you can see in line 28 of the code. Now, since this is Visual Studio Code, it includes a debugger with all its features like breakpoints, watches, and step-by-step execution. Let me show you. You can toggle a breakpoint by hovering over the gutter at the left of the line numbers and clicking on the red dot. I'll do this for line 23, which is right after getting all three numbers from the user. Now let me press F5 and I will enter three numbers again, ten, four and 2003. As you can see the execution stopped at the breakpoint and we can see the state of the local variables at the top left. I can also add an expression to the watch section. For example, birth month plus birth day. These are variables in my program and we have the usual execution buttons. Continue execution, step over, step into, step out, restart, and stop. So let's execute the rest step by step. And remember, if you close the browser you can simply open the code space again and you'll see your session right where you left it. So that's it. Try code spaces and enjoy coding on your browser without having to install anything.

Contents