C++: Creating a Console Application (2010)

Creating a Console Application (2010)

In this C++ video tutorial, we show how to create an empty C++ project in Visual C++ 2010, add a .cpp file to the project, and compile a simple program.



  1. If you have not already installed Microsoft's Integrated Development Environment (IDE), you can do so by following the directions in our lesson 0 video here.
  2. Visual C++ New Project

  3. With the Microsoft's IDE open, left-click "File" in the menubar, mouse over "New" in the submenu, and left-click "Project" in the submenu.
  4. This opens the "NewProject" dialog, which displays a set of projects to choose from. In the center pane, left-click the area labeled "Win32 Console Application" to choose your project type. Then left-click the box next "Name:" near the bottom of the dialog and enter "Lesson1" as the name of the project. Finish by left-clicking the "OK" button.
  5. This opens the "Application Wizard." Left-click the words "Application Settings" at the left to go on.
  6. This takes you to the "Application Settings." Left-click the box next to "Empty Project" and left-click "Finish" to create the project.
  7. Next, we need to add a code file to our empty project. Left-click "Project" in the menubar and "Add New Item" in the submenu.
  8. The "Add New Item" dialog should now be open. In it, you should left-click "C++ File (.cpp)" in the center pane. Then left-click the box next to "Name:" and enter "main.cpp" into it to set the name of the code file. Finish by left-clicking the "Add" button in the lower-right corner.
  9. C++ Hello World Program

  10. At this point, the file "main.cpp" has been added to our project "Lesson1." Left-click the region under the tab labeled "main.cpp" and enter this code:


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

  12. Now that the program is written, it needs to be compiled and executed. Left-click "Debug" in the menubar, and left-click "Start Debugging" in the submenu.
  13. Since the code has not yet been compiled, a dialog will come up stating that the project is out of date and asking "Would you like to build it?" Left-click the "Yes" button to compile the program.
  14. C++ Hello World Program Output

  15. If all of the code is correct, it will compile and execute and a window will pop up with the words "Hello World!" in it.