The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 ViewsI just start visual c++ today, and I'm having a problem. Whenever my console app finishes all its code, it closes. Is there a way to stop that?
abcdefghijklmnopqrstuvwxyz
You could try getting a string from the user at the end, so that it wouldn't close until there has been input.
I tried that but for some reason it works in some of my applications, and doesn't in others:(
abcdefghijklmnopqrstuvwxyz
sytem("PAUSE")
or cin.get();
att the end of your code will do it.
cin.ignore(); will work as well but i think thats not the way to go about it.
even just a cin.; will work i think
Both are generating errors? I think I'm doing something wrong, heres my code:
#include "stdafx.h"
#include <iostream.h>
int main(int argc, char* argv[])
{
int name;
cout << "Yo Jenni, enter your last name, then press enter.\n";
cin >> name;
for (int x = 0; x < 1000; x++) {
cout << "Jenni " << name << " is " << x << " times cooler than me\n" ;
}
system("PAUSE");
}
abcdefghijklmnopqrstuvwxyz
Sorry for the double post, but when I use eh-productions method, the window still closes!
abcdefghijklmnopqrstuvwxyz
You forgot the "return 0;" at the end of your code.
#include <iostream>
int main() {
//Put all your code here.
cin.get();
return 0;
}
And Love-daddy, don't use system(); calls, ever.
It's quite irritating to me when people use system calls when they're obviously not doing Winsock or Win32 API programming. Use cin.get(); for that stuff, it's annoying as hell when people use system(); and their program would be absolutely portable otherwise.
omg.
Playstation Network tag: muffin-noodle
the empty set
At 3/6/05 10:10 PM, RegExp wrote: And Love-daddy, don't use system(); calls, ever.
It's quite irritating to me when people use system calls when they're obviously not doing Winsock or Win32 API programming. Use cin.get(); for that stuff, it's annoying as hell when people use system(); and their program would be absolutely portable otherwise.
Just for the sake of argument, how do you feel about something like
void wait_at_end_of_prog() {
#if defined(WIN32)
system("pause");
#elif defined(linux)
cin.get();
#endif
}
Terrible example, but it gets the idea across.
At 3/6/05 10:20 PM, pieoncar wrote:At 3/6/05 10:10 PM, RegExp wrote: And Love-daddy, don't use system(); calls, ever.Just for the sake of argument, how do you feel about something like
It's quite irritating to me when people use system calls when they're obviously not doing Winsock or Win32 API programming. Use cin.get(); for that stuff, it's annoying as hell when people use system(); and their program would be absolutely portable otherwise.
void wait_at_end_of_prog() {
#if defined(WIN32)
system("pause");
#elif defined(linux)
cin.get();
#endif
}
Terrible example, but it gets the idea across.
I've already seen header files like that, in which a single function does such.
Unfortunately people choose to ignore that work and decide to piss off other people anyway.
omg.
Playstation Network tag: muffin-noodle
the empty set
Or how about going into the compilers options and setting the option to "not close after console application finishes".
Can't remember the exact wording, but it's there.
What may man within him hide, though angel on the outward side.
abcdefghijklmnopqrstuvwxyz
At 3/6/05 10:10 PM, RegExp wrote: And Love-daddy, don't use system(); calls, ever.
It's quite irritating to me when people use system calls when they're obviously not doing Winsock or Win32 API programming. Use cin.get(); for that stuff, it's annoying as hell when people use system(); and their program would be absolutely portable otherwise.
k thanks i'll keep that in mind dude. lol remember that im still "green" in terms of C++.