Broken example for streambuf::in_avail
Hi,
When running the example specified under
http://www.cplusplus.com/reference/iostream/streambuf/in_avail.html
(Example is included below.)
I don't get the expected answer.
# ./in_avail_prog
Please enter some characters:
asdf
The first character you entered is:
a
0 additional characters in input buffer
Is it something
compiler specific, or where do I go wrong?
I'm using sparc-sun-solaris2.9-gcc (GCC) 4.1.2
// in_avail () example
#include <iostream>
using namespace std;
int main () {
streamsize size;
char ch;
streambuf * pbuf;
pbuf = cin.rdbuf();
cout << "Please enter some characters: ";
cin >> ch;
size = pbuf->in_avail();
cout << "The first character you entered is: " << ch << endl;
cout << size << " additional characters in input buffer" << endl;
return 0;
}
/freefox
Last edited on
Topic archived. No new replies allowed.