ws


manipulator function
<istream>
istream& ws ( istream& is );

Extract whitespaces

Extracts as many whitespace characters as possible from the current position in the input sequence. The extraction stops as soon as a non-whitespace character is found. These whitespace characters extracted are not stored in any variable.

Notice that most istream objects have the skipws flag set by default, and therefore already skip all whitespaces before all extraction operations.

Parameters

is
Input stream object where to apply.
Because this function is a manipulator, it is designed to be used alone with no arguments in conjunction with the extraction (>>) operations on streams (see example below).


Return Value

The same stream object (is).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// ws manipulator example
#include <iostream>
#include <sstream>
using namespace std;

int main () {
  char a[10], b[10];

  istringstream iss ("one \n \t two");
  iss >> noskipws;
  iss >> a >> ws >> b;
  cout << a << "," << b << endl;

  return 0;
}


Basic template declaration

1
2
template <class charT, class traits>
  basic_istream<charT,traits>& ws (basic_istream<charT,traits>& is);


See also