Very Simple Program Help

Hi,
I'm a beginner in C++ and I was wondering on this issue. I have a book and I'm on page 12. Here, it gives me the code for a very basic C++ program. So, I fire up Visual Studio and proceed to type this:
#include <iostream>
using namespace std;
int main() {
cout << "This is a simple C++ program!" << endl;
}
However, when I execute, the console window opens up for less than a second, gives me the text I want and closes. Having prior experience with Visual Basic, I thought that the console window would open indefinitely. Have I written part of the code wrong? Or is it right and natural? If it is a valid code, is there any way to keep the console window open displaying the text or not?
There is a whole thread on this topic: http://www.cplusplus.com/forum/beginner/1988/

By the way, you declare your main method as returning an integer but it doesn't. You should add

return 0;

at the end.
Last edited on
Thanks man
Topic archived. No new replies allowed.