iostream hierarchy ws |
cplusplus.com |
Extract whitespaces.
Extracts and discards characters from the stream as long as the next available character is a whitespace
or until there are no more characters available.
Parameters.
Return Value.
The manipulator returns parameter is.
Example.
// whitespaces
#include <iostream>
using namespace std;
char str1[256], str2 [256];
int main () {
cout << "Please, enter some whitespaces followed by a sentence:\n";
cin >> ws;
cin.getline (str1,256);
cout << "Please, enter some whitespaces followed by a sentence:\n";
ws (cin);
cin.getline (str2,256);
cout << "You wrote:" << endl << str1 << endl << str2 << endl;
return 0;
}
This example demonstrates the two ways of calling a manipulator, both valid:
cin >> ws;
ws (cin);
Basic template declaration:
template <class charT, class traits> basic_istream<charT,traits>& ws ( basic_istream<charT,traits>& is ); |
See also.
istream class