Archived

This topic is now archived and is closed to further replies.

Anidem

Console Closing

Recommended Posts

Floppy    122
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;

Share this post


Link to post
Share on other sites
Big Sassy    311
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

Share this post


Link to post
Share on other sites