The input and output streams are defined in <iostream>, and the standard console output stream cout is also declared in this header file.
Header files containing control operators: Standard Header files <IOS> and <iomanip>
Output stream:
Boolalpha and noboolalpha: the notification output stream outputs bool to true and false (boolalpha) or 1 and 0 (noboolalpha ). The default value is noboolalpha.
Hex, Oct, and DEC: numbers are output in hexadecimal, octal, and 10hexadecimal respectively.
Setprecision: set the number of decimal places after the decimal point ). For example, setprecision (5) -- 5 digits after the decimal point.
SETW: Set the field width when the value is output. E.g. SETW (5 ).
Setfill: When the numeric width is less than the specified width, the control operator can specify characters for filling space. Setfill ('A ').
Showpoint and nonshowpoint: For floating-point numbers or double-precision numbers without decimals, this control operator forces the stream to always show decimal or decimal places.
Endl: encapsulate data and behavior. The number of notification streams outputs a carriage return and refreshes the output buffer.
The preceding control operators are written before the output parameters to be applied, such as cout <SETW (7) <setfill ('&') <variable <Endl;
E.g. # include <iostream>
# Include <iomanip>
Using namespace STD;
Int main (INT argc, char ** argv)
{
Bool testb = true;
Cout <"this is a testing of bool" <boolalpha <testb <Endl;
}
Input stream:
Boolalpha and noboolalpha: the true and false strings are interpreted as Boolean true and false for input and storage (boolalpha ). Noboolalpha does not explain this way. The default value is noboolalpha.
Hex, Oct, and DEC: numbers are read in hexadecimal, octal, and 10hexadecimal respectively.
Skipwa and noskipwa: When a notification stream performs lexical analysis, it ignores the blank space or reads the blank space as the token of a blank space.
WS: traverses the control operator. Ignore a blank string in the current position of the stream.