C++ ios Library - Noskipws Function



Description

It is used to clears the skipws format flag for the str stream. When the skipws format flag is not set, all operations on the stream consider initial whitespace characters as valid content to be extracted.

Declaration

Following is the declaration for std::noskipws function.

ios_base& noskipws (ios_base& str);

Parameters

str − Stream object whose format flag is affected.

Return Value

It returns Argument str.

Exceptions

Basic guarantee − if an exception is thrown, str is in a valid state.

Data races

It modifies str. Concurrent access to the same stream object may cause data races.

Example

In below example explains about std::noskipws function.

#include <iostream>
#include <sstream>

int main () {
   char a, b, c;

   std::istringstream iss ("  123");
   iss >> std::skipws >> a >> b >> c;
   std::cout << a << b << c << '\n';

   iss.seekg(0);
   iss >> std::noskipws >> a >> b >> c;
   std::cout << a << b << c << '\n';
   return 0;
}

Let us compile and run the above program, this will produce the following result −

123
  1
ios.htm
Advertisements