다음을 통해 공유


ios_base::setf

Sets the specified flags.

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

매개 변수

  • _Mask
    The flags to turn on.

  • _Unset
    The flags to turn off.

반환 값

The previous format flags

설명

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.

예제

// 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

요구 사항

Header: <ios>

네임스페이스: std

참고 항목

참조

ios_base 클래스

iostream 프로그래밍

iostreams 규칙