>>
will never put whitespaces into a string.
Indeed, the basic algorithm for >>
of a string
is as follows:
skip whitespace
read and extract up to but not including the next whitespace
If you use noskipws
, then the first step is skipped. Thus, with noskipws
and an input like "John Smith"
, the extract procedure never reaches "Smith"
. Instead, it endlessly outputs an empty string.
[Source]