Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining


Copies flags from one stream to another.

basic_ios& copyfmt(
   const basic_ios& _Right



The stream whose flags you want to copy.

The this object for the stream to which you are copying the flags.

The member function reports the callback event erase_event. It then copies from _Right into *this the fill character, the tie pointer, and the formatting information. Before altering the exception mask, it reports the callback event copyfmt_event. If, after the copy is complete, state & exceptions is nonzero, the function effectively calls clear with the argument rdstate. It returns *this.

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

int main( ) 
   using namespace std;
   ofstream x( "test.txt" );
   int i = 10;

   x << showpos;
   cout << i << endl;
   cout.copyfmt( x );
   cout << i << endl;


Header: <ios>

Community Additions

© 2015 Microsoft