Loading

C++: Creating a Console Application (2008)

Creating a Console Application (2008)

Assuming that you have already installed the IDE and opened it, you can run through the steps in this lesson to create your first program.



  1. In the menubar, left-click 'File,' mouse over 'New,' and left-click 'Project.' This will pop up a dialog box.
  2. Left-click 'Win32' in the 'Project Type' box. Then left-click 'Win32 Console Application' in the 'Templates' box. Finally, left-click the text box next to 'Name' and replace the text there with 'ConsoleLesson1' and click the 'OK' button.
  3. This will bring the application wizard. Left-click the 'Next' button to go to 'Application Settings.' Check the box next to 'Empty project' under 'Additional options:' by left-clicking it. Then complete the wizard by left-clicking the 'Next' button.
  4. Now, we have an empty project. To put a code file in the project, left-click 'Project' and then left-click 'Add New Item' in the menubar.
  5. This will bring up the 'Add New Item' dialog box. Now, left-click 'Visual C++' in the 'Categories' box and then left-click 'C++ File (.cpp)' in the 'Templates' box. Finally, left-click the text box next to 'Name' and replace the text there with 'main.cpp' and click the 'Add' button.
  6. Enter the 'Hello World' code shown here into the 'main.cpp' tabbed pane.


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

  8. In the menubar, left-click 'Debug' and 'Start Without Debugging' to build and execute the program.
  9. You might see a dialog box stating that 'This project is out of date' and asking if you: 'Would like to build it?' You can click the 'Yes' button, but I recommend also checking the box next to 'Do not show this dialog again' to stop this from popping up every time you run.
  10. Now you should see the console window displaying the message 'Hello World!'