help on pressing enter to continue

This is a discussion on help on pressing enter to continue within the C++ Programming forums, part of the General Programming Boards category; Hi, this may be a dumb question, but I've only been programming in C++ for a few weeks now, and ...

  1. #1
    Unregistered
    Guest

    Question help on pressing enter to continue

    Hi, this may be a dumb question, but I've only been programming in C++ for a few weeks now, and I need to make a program that, while running, will stop and ask the user to hit <return> or <enter> to continue, and actually make it do that. I have no idea how to do this...if someone could clue me in, that'd be great, thanks!!

    i.e.

    cout <<"Will Waldo make it home? Press <RETURN> to continue.";

    what next??

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You can use getchar() or cin.get() to accept input and then test for the ASCII value of 'return' to continue.
    zen

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    3
    or if you'd like to make it a little easier on yourself you can just ask for any key and use getch()

    cout <<"Will Waldo make it home? Press <ANY KEY> to continue.";
    getch();


    the getch() function will just wait until a key is pressed.... then your program will continue executing.

  4. #4
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    the getch() function will just wait until a key is pressed.... then your program will continue executing.
    Depending on your o/s and compiler.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Frustated with mess table printing
    By benedicttobias in forum C Programming
    Replies: 6
    Last Post: 04-16-2009, 06:50 PM
  2. Assignment output help
    By Taka in forum C Programming
    Replies: 13
    Last Post: 09-24-2006, 12:40 AM
  3. Moving cursor without pressing enter
    By nicolas in forum C Programming
    Replies: 3
    Last Post: 03-30-2004, 06:02 AM
  4. Press enter to continue... beginner code
    By rox in forum C Programming
    Replies: 17
    Last Post: 12-02-2003, 05:32 PM
  5. hi need help with credit limit program
    By vaio256 in forum C++ Programming
    Replies: 4
    Last Post: 04-01-2003, 12:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21