str

setf

#include <iostream>fmtflags setf(fmtflags flags);fmtflags setf(fmtflags flags1, fmtflags flags2); 

The setf( ) function is a member of ios (inherited from ios_base).

The setf( ) function sets the format flags associated with a stream. See the discussion of format flags earlier in this chapter.

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 for cout, you can use this statement:

cout.setf(ios::showpos);

When you want to set more than one flag, you can OR together the values of the flags you want set.

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.

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. 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( ).




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net