C++ iomanip Library - resetiosflags Function


Advertisements

Description

The C++ function std::resetiosflags behaves as if member unsetf were called with mask as argument on the stream on which it is inserted/extracted as a manipulator (it can be inserted/extracted on input streams or output streams).

It is used to unsets the format flags specified by parameter mask.

Declaration

Following is the declaration for std::resetiosflags function.

 resetiosflags (ios_base::fmtflags mask);

Parameters

mask − Mask representing the flags to be reset. fmtflags is a bitmask type.

Return Value

It returns unspecified. This function should only be used as a stream manipulator.

Exceptions

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

Data races

The stream object on which it is inserted/extracted is modified. Concurrent access to the same stream object may introduce data races.

Example

In below example explains about resetiosflags function.

#include <iostream>
#include <iomanip>

int main () {
   std::cout << std::hex << std::setiosflags (std::ios::showbase);
   std::cout << 100 << std::endl;
   std::cout << std::resetiosflags(std::ios::showbase) << 100 << std::endl;
   return 0;
}

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

0x64
64
iomanip.htm
Advertisements