13.5. Unformatted I/O Using read, write and gcount

Unformatted input/output is performed using the read and write member functions of istream and ostream, respectively. Member function read inputs bytes to a built-in array of chars in memory; member function write outputs bytes from a built-in array of chars. These bytes are not formatted in any way. They’re input or output as raw bytes. For example, the call

char buffer[] = "HAPPY BIRTHDAY";cout.write( buffer, 10 );

outputs the first 10 bytes of buffer (including null characters, if any, that would cause output with cout and << to terminate). The call

cout.write( "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 10 );

displays the first 10 characters of the alphabet.

The read member function inputs a designated ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.