Thread: clearing input stream

  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, 04:53 PM
  2. Strange bug with Input stream
    By Chazij in forum C++ Programming
    Replies: 12
    Last Post: 11-18-2008, 04: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, 12:08 PM
  5. text input buffer clearing
    By red_Marvin in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2003, 03:17 PM