|
-
Jun 1st, 2001, 09:04 PM
#1
Thread Starter
Member
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
-
Jun 1st, 2001, 09:18 PM
#2
Fanatic Member
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...").
Alcohol & calculus don't mix.
Never drink & derive.
-
Jun 1st, 2001, 09:19 PM
#3
Member
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
-
Jun 1st, 2001, 09:21 PM
#4
Member
Sorry Wynd!
That's the type of code I was thinking of and you beat me to it.
-
Jun 2nd, 2001, 06:29 AM
#5
Monday Morning Lunatic
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).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|