It is used to sets the basefield format flag for the str stream to dec. When basefield is set to dec, integer values inserted into the stream are expressed in decimal base (i.e., radix 10). For input streams, extracted values are also expected to be expressed in decimal base when this flag is set.
DeclarationFollowing is the declaration for std::dec function.
ios_base& dec (ios_base& str);Parameters
str − Stream object whose format flag is affected.
Return ValueIt returns Argument str.
ExceptionsBasic guarantee − if an exception is thrown, str is in a valid state.
Data racesIt modifies str. Concurrent access to the same stream object may cause data races.
ExampleIn below example explains about std::dec function.
#include <iostream> int main () { int n = 70; std::cout << std::dec << n << '\n'; std::cout << std::hex << n << '\n'; std::cout << std::oct << n << '\n'; return 0; }
Let us compile and run the above program, this will produce the following result −
70 46 106
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