C++ ios Library - Nouppercase Function



Description

It is used to sets the uppercase format flag for the str stream. When the uppercase format flag is set, uppercase (capital) letters are used instead of lowercase for representations on output operations involving stream-generated letters, like some hexadecimal representations and numerical base prefixes.

Declaration

Following is the declaration for std::uppercase function.

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

#include <iostream>

int main () {
   std::cout << std::showbase << std::hex;
   std::cout << std::uppercase << 77 << '\n';
   std::cout << std::nouppercase << 77 << '\n';
   return 0;
}

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

0X4D
0x4d
ios.htm
Advertisements