Reputation: 21885
Given this little piece of code
//============================================================================
// Name : prwe.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
cout << "Hello World" << endl; // prints Hello World
return 0;
}
This code compiles under Eclipse ,but nothing is presented in the Console window .
Any idea what did I do wrong ?
Thanks
Upvotes: 2
Views: 1247
Reputation: 108
The program runs, prints Hello World, and closes before you can see it.
add
cin.get();
before the return 0; and it should be working fine. Then, you will have to hit enter to close the console.
What cin.get(); is doing is requiring user input to continue, and in this case continuing closes the program.
Upvotes: 6