Thread: press enter to continue

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    81

    press enter to continue

    In anyone's opinion, what would be the best way to stop the program saying to the user "Press enter to continue"?
    "Our greatest glory consists not in never failing,
    but in rising every time we fall."

    Oliver Goldsmith (1730-1774).
    Anglo-Irish writer, poet and playwright.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is the function ignore().

    Code:
    cout << "\nPress Enter to continue.\n";
    cin.ignore(256, '\n');
    Kuphryn

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    81
    what I mean is this

    Code:
    	cout << "Press enter to roll";
    	cin >> str;
    Now, str takes any letter but not enter. I would like to know how to have the user use enter to make the program continue.
    "Our greatest glory consists not in never failing,
    but in rising every time we fall."

    Oliver Goldsmith (1730-1774).
    Anglo-Irish writer, poet and playwright.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    81
    Thanks for the reply. But cin.ignore(256, '\n'); does not work. The program just keeps going.
    "Our greatest glory consists not in never failing,
    but in rising every time we fall."

    Oliver Goldsmith (1730-1774).
    Anglo-Irish writer, poet and playwright.

  5. #5
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Now, str takes any letter but not enter. I would like to know how to have the user use enter to make the program continue.
    Well u could use virtual keys (<windows.h>) and do this:

    do
    {
    ....
    ....
    .....
    ....
    }

    while (str != VK_ENTER)


    This is just real quick its not rlly accurate but u get the idea.

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Code:
    int main(void)
    {
        cout << "\nPress Enter to continue.\n";
        while (cin.get() != '\n');
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    81

    THANKS!

    Just wanted to thank everyone that took to time to read and answer the post. Your answers are always helpful and they always teach me different solutions to my problem. It's a great help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 10:06 AM
  2. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  3. Enistine program
    By Mac_the vamp in forum C Programming
    Replies: 2
    Last Post: 11-11-2002, 10:56 AM
  4. help on pressing enter to continue
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-06-2001, 11:08 AM
  5. Pause or press any key to continue
    By muffin in forum C Programming
    Replies: 3
    Last Post: 09-12-2001, 12:26 PM