Oracle® Solaris Studio 12.4: C++ User's Guide

Exit Print View

Updated: March 2015
 
 

13.3.8 Extracting Whitespace

By default, the iostream extractors skip leading whitespace. The following example turns off whitespace skipping from cin, then turns it back on:

cin.unsetf(ios::skipws); // turn off whitespace skipping
...
cin.setf(ios::skipws); // turn it on again

You can use the iostream manipulator ws to remove leading whitespace from the iostream regardless of whether skipping is enabled. The following example shows how to remove the leading whitespace from iostream istr:

istr >> ws;