Re: [LIP] std::cin.readsome(...) and std::cin.rdbuf()->in_avail()
"Josy P. Pullockara" <[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Organization | National Aerospace Laboratories |
| Message-ID | <[email protected]> |
On Wed, 2003-12-03 at 04:30, Bhaskar Dutta wrote:
> >>> On Tuesday 02 December 2003 08:33 pm, JP <Josy P. Pullockara> said:
> JP> When it is undesirable to wait for input from a keyboard to std::cin
> In UNIX, pressing ctrl-D at the start of a line acts as end-of-file. Pressing
> it somewhere else within a line in your program doesn't work. (check it out!)
Thanks for this info. I did not notice this. I would be happy to know
how std::cin handles that situation of <ctrl-D> in the beginning of the
line and discarding it at other places!
> declare a string (or whatever data you wanna force from user), eg str, and do
>
> while (std::cin >> str){.....}
>
> As soon as you press ctrl-d, this conditional fails and your program exits.
This is not suitable. Read the first line in my post (reproduced above)
- I do not want to WAIT for inputs, but when the inputs appear I do want
to read them. In some sense I want UNBUFFERED input. But
std::cin.rdbuf()->pubsetbuf(0,0);
does not seem to do this on Linux/SGI (<streambuf>: setbuf() is just a
dummy). I have not tried on other platforms!
> Your code suggests that you want to manipulate the stream directly. So you wud
> probably have to find a workaround if you want to use cin::rdbuf->in_avail()
I do not want to manipulate the stream directly! I just do not want to
wait for inputs!
> else change the code as cin is no longer required. In fact it gets
> simpler and shorter this way.
I did not get your point. How does it get simpler and shorter when I
want to read from the terminal without using std::cin!
Thank you.
--
Josy P. Pullockara <[email protected]>
National Aerospace Laboratories
-------------------------------------------------------
This SF.net email is sponsored by OSDN's Audience Survey.
Help shape OSDN's sites and tell us what you think. Take this
five minute survey and you could win a $250 Gift Certificate.
http://www.wrgsurveys.com/2003/osdntech03.php?site=8