Subject: c++ iostream clear method
To: None <>
From: Mark Davies <>
List: current-users
Date: 09/26/2001 23:02:15
I was going to PR this but can't decide what category it is so thought I'd
mention it here in the meantime.

The following little c++ program demonstrates a problem with the iostream clear
method on at least the i386 port.

#include <iostream.h>

        char ans;

        cout << "Hello World: ";
        cin >> ans;
        cout << "Hi again: ";
        cin >> ans;


Compiling and running this on 1.5X, if you type CNTL-D at the first prompt,
it drops through the second and exits with the cin.clear() appearing not to
clear the EOF status on standard in. This is with the standard system g++
and the same thing happens with the 2.95.2 from pkgsrc - I haven't tried
with the new toolchain.

This same code, compiled with various versions of g++, on Tru64 and
Solaris8 sits at the second prompt waiting for more input so its not a
general g++/libstdc++ problem but specific to NetBSD.