Thread: cin.get() pauses the program?

  1. #1
    the Wizard
    Join Date
    Aug 2004
    Posts
    109

    cin.get() pauses the program?

    Hi,

    I've run into a problem,

    I have a switch-statement like this:
    Code:
    switch(chMenu)
    {
     case 1:
      //Code
     break;
     
     case 2:
      //code
      cout << "Press a button to continue.." << endl;
      cin.get();
     break;
    }
    Shouldn't the cin.get(); pause the program until the uses presses a button?

    Does anybody have a solution to the problem?
    Anything but system("pause");
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Its probably because you are using a cin>> before your cin.get(). cin>> leaves the '\n' in the input stream and your cin.get() picks up on it.
    Read This lovely tip:
    http://www.cprogramming.com/tips/sho...ount=30&page=0
    Woop?

  3. #3
    the Wizard
    Join Date
    Aug 2004
    Posts
    109
    Oh..
    Didn't knew that.
    Thx alot
    -//Marc Poulsen -//MipZhaP

    He sat down, he programmed, he got an error...

  4. #4
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    You are quite welcome.
    Woop?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM