Feedback

/Hello World in C++ using Visual Studio 2017
Technical Support & FAQs | Visual Studio IDE 2018-04-11T16:06:42+00:00

Get help with Visual Studio

Contact us
Support

Visual Studio 2017 FAQ

Hello World in C++ using Visual Studio 2017

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

  1. First, understand the layout and views once you launch Visual Studio 2017: 2017-03-09%2013_52_37-Start%20Page%20-%20Microsoft%20Visual%20Studio.png
  2. Next, review the 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++ through the Visual Studio Installer: C%2B%2B%20Tutorial%2C%20Installing%20C%2B%2B.png
  4. After installing the Desktop development with C++ workload, you can choose the Win32 Console Application template and create your HelloWorld project: C%2B%2B%20Tutorial%2C%20New%20Project%20Dialog.png
  5. Click Finish to exit the Win32 Application Wizard C%2B%2B%20Tutorial%2C%20Wizard.png
  6. You can see your first C++ project: C%2B%2B%20Tutorial%2C%20Editor.png
  7. Replace the code with below lines:
    #include "stdafx.h"
    #include <iostream> 
    using namespace std;    
    
        int main()      
        {    
            cout << "Hello World! ";    
            return 0;      
        }
    
  8. Next, add a breakpoint by clicking the grey area in front of line 12: 2017-03-09%2013_47_14-HelloWorld%20-%20Microsoft%20Visual%20Studio.png
  9. Compile and run your project by clicking the green triangle in the tool bar (Local Windows Debugger) or press F5. Visual Studio allows single-click for build and debugging. Click Yes to build the project: 2017-03-09%2013_47_47-Microsoft%20Visual%20Studio.png
  10. You can see a "Hello World!" in the console window.
Troubleshooting: If the console window immediately closes, you need to set the breakpoint in step 8. 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! Please let us know whether you find this article useful or not. Thank you!

Contact Us!