The main algorithm for >>
string is:
skip whitespace read and extract until next whitespace
If you are using noskipws
, then the first step is skipped. After the first reading, you fall into spaces, so the next (and all subsequent) reading stops immediately without extracting anything.
>>
a string will never fit a space in a string. More generally, using >>
with noskipws
problematic, since space is always a separator for >>
; it may make sense to use it punctually, but usually it should be reset immediately after using it. (The case where this makes sense is to use >>
before char
. In this case, the stream always extracts one character.)
source share