clearing input stream

This is a discussion on clearing input stream within the C++ Programming forums, part of the General Programming Boards category; Can anyone tell me how to clear the entire input stream when you have used cin.get(etc.). I have been using ...

  1. #1
    Sub
    Guest

    Question clearing input stream

    Can anyone tell me how to clear the entire input stream when you have used cin.get(etc.). I have been using cin.clear but that it only clearing the fail bit.

    Thanks.

  2. #2
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    Header File

    stdio.h

    Category

    Input/output Routines

    Syntax

    #include <stdio.h>
    int fflush(FILE *stream);

    Description

    Flushes a stream.

    If the given stream has buffered output fflush writes the output for stream to the associated file.

    The stream remains open after fflush has executed. fflush has no effect on an unbuffered stream.

    Return Value

    fflush returns 0 on success. It returns EOF if any errors were detected.

    try that...

    Regards,
    matheo917

  3. #3
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    or to be simple ...
    right after the "cin" you put...

    cout << endl;

    --- which flushes the buffer....

    or maybe you are looking to flush every single stream????

    Regards,
    matheo917

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to declare a global input stream
    By Chazij in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2008, 03:53 PM
  2. Strange bug with Input stream
    By Chazij in forum C++ Programming
    Replies: 12
    Last Post: 11-18-2008, 03:52 PM
  3. reading from input stream
    By Micko in forum C++ Programming
    Replies: 8
    Last Post: 05-01-2005, 05:50 PM
  4. Clearing the Input buffer
    By Brain Cell in forum C Programming
    Replies: 5
    Last Post: 03-21-2004, 11:08 AM
  5. text input buffer clearing
    By red_Marvin in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2003, 02:17 PM

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