C++ ios Library - Noshowbase Function



Description

It is used to clears the showbase format flag for the str stream. When the showbase format flag is not set, numerical values are inserted into the stream without prefixing them with any numerical base prefix (i.e., 0x for hexadecimal values, 0 for octal values and no prefix for decimal-base values).

Declaration

Following is the declaration for std::noshowbase function.

ios_base& noshowbase (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::noshowbase function.

#include <iostream>

int main () {
   int n = 20;
   std::cout << std::hex << std::showbase << n << '\n';
   std::cout << std::hex << std::noshowbase << n << '\n';
   return 0;
}

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

0x14
14
ios.htm
Advertisements