Partager via


ios_base::setf

Sets the specified flags.

fmtflags setf(
    fmtflags _Mask
);
fmtflags setf(
    fmtflags _Mask,
    fmtflags _Unset
);

Parameters

  • _Mask
    The flags to turn on.

  • _Unset
    The flags to turn off.

Return Value

The previous format flags

Remarks

The first member function effectively calls flags(_Mask | _Flags) (set selected bits) and then returns the previous format flags. The second member function effectively calls flags(_Mask & fmtfl, flags & ~_Mask) (replace selected bits under a mask) and then returns the previous format flags.

Example

// ios_base_setf.cpp
// compile with: /EHsc
#include <iostream>

int main( ) 
{
   using namespace std;
   int i = 10;
   cout << i << endl;

   cout.unsetf( ios_base::dec );
   cout.setf( ios_base::hex );
   cout << i << endl;

   cout.setf( ios_base::dec );
   cout << i << endl;
   cout.setf( ios_base::hex, ios_base::dec );
   cout << i << endl;
}

Output

10
a
10
a

Requirements

Header: <ios>

Namespace: std

See Also

Reference

ios_base Class

iostream Programming

iostreams Conventions