setf
Syntax:
#include <fstream> fmtflags setf( fmtflags flags ); fmtflags setf( fmtflags flags, fmtflags needed ); The function setf() sets the io stream format flags of the current stream to flags. The optional needed argument specifies that only the flags that are in both flags and needed should be set. The return value is the previous configuration of io stream format flags. For example: int number = 0x3FF; cout.setf( ios::dec ); cout << "Decimal: " << number << endl; cout.unsetf( ios::dec ); cout.setf( ios::hex ); cout << "Hexadecimal: " << number << endl; Note that the preceding code is functionally identical to: int number = 0x3FF; cout << "Decimal: " << number << endl << hex << "Hexadecimal: " << number << dec << endl; thanks to io stream manipulators. |