-
Console Problems
Hey people,
I'm a newbie at C++ and am taking things nice and slowly for the moment. I've created my first C++ program "Hello World". It compiles correctly but when i run the program all it does is pop up and disappear in less than a second. The code is as follows:
/**************************************************/
#include <IOSTREAM>
int main ()
{
std::cout << "Hello World!\n"; // Displays Hello World
return 0;
}
/**************************************************/
I can't figure out what's going wrong. I'm using Dev C++ to create my programs. Can anyone give me any pointers as to the problem? Could it be to do with the enviroment or compiler options?
-
The FAQ has a lot of useful answers in it. I suggest you peruse it sometime. :)
-
Welcome to the board
Please use [code][/code] tags around your future code posts.
-
I notice the new VC++ 8 compiler actually pauses after a program whether or not you add code to tell it to do so. You could always just switch to this compiler if you are a winbloze user.
-
MinGW Studio does the same. And honestly I would suggest it over anything else (free wise).
Check out the link in my signature.
Also, the reason it does this is because it is the "debug" build of the application. So the "release" build wont have that.
And a quick answer to your question.
Code:
#include <iostream>
int main ()
{
std::cout << "Ah";
// This will wait for you to hit enter
std::cin.get ();
return 0;
}
Still, go and read the FAQ. Alot of good stuff in there.