Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Help for a beginner

Hello, I'm just getting started with C++. I got the program Dev-C++.
I bought a book for complete beginners. But I can't even get the first example [ Hello World ] right. All that happens when I compile and run it is that I see a window appearing on the screen and then disappearing really fast again.
Here's the code:

#include <iostream>
using namespace std;

int main()
{
cout << "Hello World\n";
return 0;
}
[484 byte] By [Pinny] at [2007-11-11 7:32:09]
# 1 Re: Help for a beginner
Most everyone who has used Dev-C++ has faced this, too.

One of the methods which will allow you to view the console (in a DOS or Windows version) is, before your return statement, add this statement to your main method:

system( "pause");

It freezes the display with an operating system message "Press any key to continue".

This is one of the items contained in the Dev-C++ FAQ files which are included with the IDE - go to help, index, type in FAQ ...
nspils at 2007-11-11 21:02:10 >
# 2 Re: Help for a beginner
Ah yes, that works.
Thanks a lot! :)
Pinny at 2007-11-11 21:03:16 >