-
Program unlaods???
Hi,
I'm currently learning C++ and I copied one simplest program from the book to my compiler, and then I compiled it.
#incude<iostream.h>
int main()
{
cout << "Hello World \n";
return 0;
}
After I ran the program, I noticed that it loads and automatically unlaods. How do I make it load, stay loads, and when I press the "x" button in the right hand corner, it will unlaod?
Thanks
-
Code:
#incude <iostream.h>
#include <stdio.h>
int main()
{
cout << "Hello World \n";
system("pause");
return 0;
}
This will pause the program until you press a key (oddly enough it says "Press any key to continue...").
-
There better ways to do this but this will work...
Code:
#include <iostream.h>
int main()
{
char nothing=0;
cout << "Hello World \n";
cin >> nothing;
return 0;
}
just hit any key on the keyboard and then enter to exit.
chilibean
-
Sorry Wynd!
That's the type of code I was thinking of and you beat me to it.;)
-
If it's in a console window you shouldn't use the X button to close it, because that can prevent it from cleaning up after itself (the compiler adds a lot more after your main() function has finished).