ios& copyfmt ( const ios& rhs );

Copy formatting information.
  Copies the values of all the internal members of object rhs except the state flags and the stream buffer pointer to the corresponding members of *this. This includes the format flags, the fill character, the tie pointer and all formatting information. Every external object pointed in rhs is copied to a newly constructed object for *this.


Object whose members are to be copied to *this

Return Value.
  The function returns *this.


// copying formatting information
#include <iostream>
#include <fstream>
using namespace std;

int main () {

  ofstream filestr; ("test.txt");

  cout.fill ('*');
  cout.width (10);
  filestr.copyfmt (cout);

  cout << 40;
  filestr << 40;

  return 0;
This example outputs a number formatted in the same way in bot cout and filestr:

Basic template member declaration ( basic_ios<charT,traits> ):
basic_ios& copyfmt (const basic_ios& rhs );

See also.
  tie, fill, width, fmtflags, iostate, locale
  ios class

© The C++ Resources Network, 2001