Now that you’ve successfully compiled your code and created an executable program, it’s time to run it!

There are two different ways we will usually run our programs in this course: via the command line, or via Visual Studio’s “Start Debugging” button.

Option 1: Start your program on the command line

Warning

The rest of this tutorial assumes you’re using a Powershell terminal from within Visual Studio. If you decide to use the command prompt or use a terminal outside of Visual Studio, be advised that certain commands may not match or produce the output in the tutorial.

Let’s say your code file is called MyCode.c, and your compilation produced an executable called MyCode.exe. From our powershell terminal in VS, we can type the following command:

./MyCode.exe

This will run our program! You should be able to see the program’s output in the powershell terminal:

This is the program output! 
This program just prints some text, and doesn't do anything important.

Option 2: Start your program via the “Start Debugging” button

We will usually run our programs this way when we want to use Visual Studio’s debugger to find a bug. But we don’t need to be debugging to use this option; you may find it more convenient than starting your program from the terminal.

Note that using the “Start Debugging” button isn’t actually sufficient if we want to debug our program in the debugger; you will need to compile your code using the MSVC debug flag, and set breakpoints in your code. Visit the debugging note for more info on using the debugger.