Thread: putting a pause in?

  1. #1
    Registered User DocDroopy's Avatar
    Join Date
    Jul 2002
    Posts
    32

    putting a pause in?

    If I wanted a program to pause at the completion of a function, and have any key pressed allow the program to continue, what would be the easiest way to do that?

    Thanks for the help
    DD

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    That's a very common question on the board.

    Make sure that you've read the faq or done a board search before you post.

    But anyway, there are many ways that one could do it.

    Here are a few:

    getc() - needs stdio.h
    getch() - needs conio.h
    getchar() - unsure

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    you could use this

    if <conio.h> is available to you
    Code:
    printf("Hit any key to continue");
    getch();
    if not
    Code:
    printf("Hit any key to continue");
    fflush(stdin);
    getchar();

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >getch();
    getch is non-standard, it's best to remain standard whenever possible. If I need a pause then I'll use getchar in stdio.h.

    >fflush(stdin);
    Perhaps you meant fflush ( stdout ). fflushing input streams is undefined.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User DocDroopy's Avatar
    Join Date
    Jul 2002
    Posts
    32

    Talking Thanks

    Thanks guys,

    Got it working, as always I greatly aprecaite the help.

    DD
    "aut vincere aut mori"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Fork(), pause(), and storing PID's in a linked list
    By vital101 in forum C Programming
    Replies: 10
    Last Post: 09-28-2007, 02:16 AM
  3. Pong, Need help with paddles and pause
    By trev456 in forum C++ Programming
    Replies: 8
    Last Post: 04-15-2007, 04:45 AM
  4. Dev-C++ Compile and Run with Pause
    By xmltorrent in forum C++ Programming
    Replies: 12
    Last Post: 03-29-2006, 11:55 PM
  5. Pause function ???
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 09-02-2001, 08:22 PM