Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Console Closing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Anidem   Members   -  Reputation: 132

Like
Likes
Like

Posted 28 January 2002 - 05:25 PM

How can I keep the console from closing, ii''m using c++.

Sponsor:

#2 Floppy   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 January 2002 - 05:30 PM

What console are you referring too? bash, ms-dos, csh, tcsh, etc.

#3 Anidem   Members   -  Reputation: 132

Like
Likes
Like

Posted 28 January 2002 - 05:55 PM

the cmd console, which i guess is ms-dos

#4 Floppy   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 January 2002 - 06:06 PM

Ok, so I guess your using Windows. Well, the easiest way I suppose is to use getchar to wait for a key to be pressed; when the key is pressed the program exits. For example:
  
#include <stdio.h>

int main()
{
// Some code


// Wait for some input from the keyboard

getchar();

// Exit the program by closing the console

return 0;


#5 Big Sassy   Members   -  Reputation: 310

Like
Likes
Like

Posted 28 January 2002 - 06:07 PM

You could always inlude conio.h and put getch() at the end of your code

    

#include <conio.h>

void main()
{
// do stuff

getch();
}


EDIT - Whoops. Looks like Floppy beat me too it. They both basically do the same thing. Have fun

Edited by - Big Sassy on January 29, 2002 1:09:24 AM

#6 Anidem   Members   -  Reputation: 132

Like
Likes
Like

Posted 29 January 2002 - 01:25 PM

thanks

#7 Gummo   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 January 2002 - 03:17 PM

I prefer


#include <stdlib.h>

int main()
{
system("PAUSE");
return 0;
}





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS