-6

Does anyone know why my Hello world won't print anything?

Here is the process I went through so far:

  • I downloaded Visual Studio 2015.
  • I created a new project and named it Hello world and checked empty to remove the pre compiled headers.
  • After that I went to the source tab >insert new item and made a new item, the main function, and named it main.cpp.
  • After writing my code I pressed ctrl+5 and the command prompt appears, but it's blank.

VS also tells me that my project is out of date before I build it, but I heard this isn't anything to worry about.

Here's my code

#include <iostream>

using namespace std;

int main() {

    cout << "Hello World!" << endl;

    return 0;

    cin.get();
}

And a picture of what I'm getting after pressing ctrl+5 and build.

TZHX
  • 5,291
  • 15
  • 47
  • 56
Wavey
  • 15
  • 2

1 Answers1

5

The return 0 line is going to end the program before cin.get() gets executed.

Flip the order of return 0 and cin.get().

jglouie
  • 12,523
  • 6
  • 48
  • 65