Quote:
Originally posted by Ian W.
ok, i've figured out the 'cin.rdbuf( )->in_avail( )' line seems to always equal 0, no matter what i do. how do i change this?
|
cin.rdbuf( )->in_avail( ) should return non zero (greater than zero) if there is data in the keyboard buffer. Is this not the case? When you say "no matter what i do" does that include pressing keyboard keys (other than Ctrl-C which is probably handled differently than other keys)? (I know that may sound insulting. That's not my intention. I have worked on a help line, and I've learned to not take
anything for granted.) If you are able to read data from the keyboard using cin, then in_avail() should also work.
BTW, for readability (probably not efficiency) you could save the return value of cin.rdbuf() in a variable (say cinBuffer) -- outside the loop and then only call cinBuffer->in_avail() inside the loop.