cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : ios : copyfmt
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
ios
· ios::ios
· ios::~ios
member functions:
· ios::bad
· ios::clear
· ios::copyfmt
· ios::eof
· ios::exceptions
· ios::fail
· ios::fill
· ios::good
· ios::imbue
· ios::init
· ios::narrow
· ios::operator!
· ios::operator void*
· ios::rdbuf
· ios::rdstate
· ios::setstate
· ios::tie
· ios::widen

-

ios::copyfmt public member functions
ios& copyfmt ( const ios& rhs );

Copy formatting information

Copies the values of all the internal members of the 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.

The exception mask is the last to be copied.

Before copying any parts of rhs, this member function triggers an erase_event event which invokes the registered callback functions, if any (see ios_base::register_callback).

Parameters

rhs
Object whose members are to be copied to *this

Return Value

The function returns *this.

Example

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

int main () {

  ofstream filestr;
  filestr.open ("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 both cout and filestr:

********40

Basic template member declaration

( basic_ios<charT,traits> )
basic_ios& copyfmt (const basic_ios& rhs );

See also

ios::tie Get/set the tied stream (public member function)
ios::fill Get/set the fill character (public member function)
ios_base::width Get/set field width (public member function)
ios_base::fmtflags Type for stream format flags (public member type)

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us