flushing invalid output

This is a discussion on flushing invalid output within the C++ Programming forums, part of the General Programming Boards category; // for example int choice=0; cout<<"Enter your choice please\n"; cin>>choice; Question: If the user enters an integer, it is alright. ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    13

    flushing invalid output

    // for example

    int choice=0;
    cout<<"Enter your choice please\n";
    cin>>choice;

    Question: If the user enters an integer, it is alright. However, if he enters lets say an alphabet, what should I do to flush the input out. Or else, the screen will flood. Thanks!

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Read the FAQ . There's plenty of help in there
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    13

    reply

    lol. i am quite ........one lar anyway thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. New to C++ Classes
    By Cypher in forum C++ Programming
    Replies: 122
    Last Post: 07-05-2007, 01:49 PM
  3. Merge Sort - Invalid Output ??
    By gqchynaboy in forum C++ Programming
    Replies: 3
    Last Post: 09-25-2005, 05:01 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM

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