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;