There is no ostream& write ( const char* s , streamsize n ) function ostream& write ( const char* s , streamsize n ) . Perhaps you mean the member function ostream& ostream::write ( const char* s , streamsize n ) ?
The .write() function is called raw (or unformatted) output. It simply outputs a sequence of bytes into the stream.
The global variable cout is one instance of the ofstream class and has a .write() method. However, cout usually used for formatted output, for example:
string username = "Poulami"; cout << "Username: '" << username << "'." << endl;
Many different types have ostream& operator<<(ostream& stream, const UserDefinedType& data) , which can be overloaded to enrich the ofstream dictionary.
source share