C++: Creating a Console Application in Visual Studio 2012

Creating a Console Application in Visual Studio 2012

In this C++ video tutorial, we show how to create an empty C++ project in Visual Studio 2012, add a .cpp file to the project, and compile a simple program. These steps will be used at the start of most of the remaining videos, but they will not be repeated.

  1. If you have not already installed Microsoft Visual Studio, you can do so by following the directions in our lesson 0 video here.
    Lesson 0 Page
  2. To begin, start Visual Studio 2012
    1. For Windows 7 or earlier, left-click the Start button, and left-click the Visual Studio icon in the drop-down list to start Visual Studio.
    2. For Windows 8, move the cursor up to the upper-right corner and then move it down to left-click the Start icon. This brings you to the "Start" screen. Left-click the scroll bar at the bottom of the screen and drag it all the way to the right. Now you should see the Visual Studio 2012 icon. Left-click it to start Visual Studio 2012.
  3. As Visual Studio starts up, you may see a message box warning you that This program has compatibility issues. Update the installation by left-clicking Get online help and following the steps to update the installation.
  4. After this, you should have Visual Studio 2102 open. Left-click FILE in the menubar and then left-click New Project in the submenu.
  5. Then you should see the "New Project" dialog open. Left-click Visual C++ and then left-click Win32 Console Application. Next, left-click the box next to Name: and enter "ConsoleLesson1" in the box. Left-click the OK button to go on.
    New Project Dialog
  6. This opens the "Win32 Application Wizard." Left-click the Application Settings link.
  7. In the "Application Settings," left-click the box next to Empty Project to select it. Then left-click the Finish button to create and open the new project.
  8. With the empty project created, we need to add a code file. Left-click PROJECT in the menubar and then left-click Add New Item... in the submenu to open the "Add New Item" dialog.
  9. In the "Add New Item" dialog, left-click Visual C++ and then left-click C++ File. Then left-click the box next to Name: and enter "main.cpp" in the box. Finish by left-clicking the Add button.
    Add New CPP File
  10. Your project should now have the file "main.cpp" in it. Left-click inside the main pane and add this code:

    #include <iostream>
    int main() {
        std::cout << "Hello World!" << std::endl;
        return 0;

  11. That is the entire program. To run it, left-click DEBUG in the menubar, and then left-click Start Without Debugging in the submenu to compile and execute the program.
  12. At this point, you should see a message box asking you if you would like to build the project. Left-click the Yes button to continue.
  13. If you have typed or copied the program correctly, it should compile and execute, and you should see the console window with the message "HelloWorld!" in it.
    Console Window