Results 1 to 3 of 3

Thread: Is there any way to pause a console program?

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    For example, at the end of a program it says "Press any key to continue", but you can't really see any output because it closes too fast. Is it possible to have the program wait for a keypress before proceeding?

  2. #2
    Guest
    Code:
    #include <conio.h>
    #include <iostream.h>
    
    int main()
    {
    //do stuff here.
    
    //end of program
    cout << "Press any key to continue";
    getch();
    return 0;
    }

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    At the very end of your main() function, put:
    Code:
    #include <stdlib.h>
    ....
    system("pause");
    return 0;
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width