Skip to content
/Hello World in C++ using Visual Studio 2019
Hello World in C++ using Visual Studio 20192019-04-11T20:31:51-07:00

Get help with Visual Studio

Support links

Top issue FAQs

Hello World in C++ using Visual Studio 2019

Thank you for downloading Visual Studio and starting your first C++ journey!

  1. First, understand the layout and views once you launch Visual Studio 2019.

    Screenshot of Visual Studio 2019 launch window

  2. Next, review the standard build process for a Visual Studio project.

    Graphic depiction of standard build process for a Visual Studio project

  3. If C++ is not an already installed language in Visual Studio, you need to install Desktop development with C++ from the Visual Studio Installer.

    Screenshot of the Desktop development with C++ installer option selected

  4. After installing the Desktop development with the C++ workload, open Visual Studio 2019, and click Create a new project to start creating your HelloWorld project.

    Screenshot of the Create a new project dialog

  5. Select Language as C++, Platform as Windows, and Project Type as Console. Then select Console App and click Next.

    Create new project dialog box with C++ selected as the Language, Windows selected as the platform, Console selected as the Project type, and the Console App option selected

  6. Type “HelloWorld” as the project name and click Create.

    Screenshot of the Configure your new project dialog with the project name specified as HelloWorld.

  7. You can see your first C++ project.

    Screenshot of the first C++ project

  8. Replace the code with the following:
    #include "stdafx.h"
    #include <iostream> 
    using namespace std;    
    
        int main()      
        {    
            cout << "Hello World! ";    
            return 0;      
        }
    

    Updated code for the HelloWorld project

  9. Compile and run your project by clicking the green triangle in the tool bar (Local Windows Debugger) or press F5 to Run in Debug Mode. Use Ctrl+F5 to run in Release Mode. Visual Studio allows single-click for build and debugging. Click Yes to build the project.
  10. You can see “Hello World!” in the console window.

    Screenshot of Hello World displayed in the console window

Troubleshooting information:

If the console window closes immediately, you need to set the breakpoint on line 8 in step 7.

If you are on Windows 8.1, you need to re-run the installer for Visual Studio, click modify, select languages, and choose C++.

Congratulations on your first C++ project!

Support links

Feedback