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_right.htm below:

C++ ios Library - Function Right

C++ ios Library - Function Right Description

It is used to sets the adjustfield format flag for the str stream to right. When adjustfield is set to right, the output is padded to the field width (width) by inserting fill characters (fill) at the beginning, effectively adjusting the field to the right.

Declaration

Following is the declaration for std::right function.

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

#include <iostream>

int main () {
   int n = -77;
   std::cout.width(6); std::cout << std::internal << n << '\n';
   std::cout.width(6); std::cout << std::left << n << '\n';
   std::cout.width(6); std::cout << std::right << n << '\n';
   return 0;
}

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

-   77
-77
   -77

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