#include <iostream.h>long setf(long flags);long setf(long flags1, long flags2);
The setf( ) function is a member of ios.
The first version of setf( ) turns on the format flags specified by flags. (All other flags are unaffected.) For example, to turn on the showpos flag, you can use this statement:
Here, stream is the stream you wish to affect.
It is important to understand that a call to setf( ) is done relative to a specific stream. There is no concept of calling setf( ) by itself. Put differently, there is no concept in C++ of global format status. Each stream maintains its own format status information individually.
When you want to set more than one flag, you can OR together the values of the flags you want set.
The second version of setf( ) affects only the flags that are set in flags2. The corresponding flags are first reset and then set according to the flags specified by flags1. It is important to understand that even if flags1 contains other set flags, only those specified by flags2 will be affected.
Both versions of setf( ) return the previous settings of the format flags associated with the stream.
Related functions are unsetf( ) and flags( ).