C++ Manipulator hexC++ manipulator hex function is used to set the basefield format flag for the str stream. When we set basefield to hex, then integer values inserted into the stream are expressed in hexadecimal base (i.e. radix 16). For input streams, when this flag is set, then extracted values are also expected to be expressed in hexadecimal base. SyntaxParameterstr: stream object whose format flag is affected. Return valueIt returns argument str. Data RacesData races may cause when modifies str concurrent access to the same stream object. Exceptionsstr is in a valid state, if an exception is thrown. Example 1Let's see the simple example to demonstrate the use of hex: Output: 2710 Example 2Let's see another simple example: Output: 24 18 30 Example 3Let's see another simple example: Output: The number 42 in octal: 52 The number 42 in decimal: 42 The number 42 in hex: 2a Parsing "2A" as hex gives 42
Next TopicC++ Manipulator
|