A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_uppercase.htm below:

C++ ios::Uppercase() Function

C++ ios::Uppercase() Function

The C++ std::ios::uppercase() function is used to modify the behaviour of stream output operations. When it is invoked, it makes the characters to be displayed in uppercase. This manipulator is used with the output streams to ensure that the numeric values are printed in uppercase hexadecimal format, and for other characters where uppercase representation is desired.

Syntax

Following is the syntax for std::ios::uppercase() function.

ios_base& uppercase (ios_base& str);
Parameters Return Value

This function returns the Argument str.

Exceptions

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 the following example, we are going to consider the basic usage of the uppercase() function with hexadecimal format.

#include <iostream>
#include <iomanip>
int main()
{
    int x = 1234;
    std::cout << "Result :  " << std::hex << std::uppercase << x << std::endl;
    return 0;
}
Output

Output of the above code is as follows −

Result :  4D2
Example

Consider the following example, where we are going to use the uppercase() function along with the showbase().

#include <iostream>
#include <iomanip>
int main()
{
    int x = 1234;
    std::cout << std::hex << std::uppercase << std::showbase;
    std::cout << "Result : " << x << std::endl;
    return 0;
}
Output

Following is the output of the above code −

Result : 0X4D2
Example

Let's look at the following example, where we are going to use the uppercase() in a function.

#include <iostream>
#include <iomanip>
void a(int num)
{
    std::cout << std::hex << std::uppercase << num << std::endl;
}
int main()
{
    a(2234);
    a(2232);
    return 0;
}
Output

If we run the above code it will generate the following output −

8BA
8B8

ios.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4