read [C++ Reference]
Keywords: io,read
Date: 2009-03-09T12:21:43-0700

[[read]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## read

Syntax:

        istream& istream::read( char* buffer, streamsize num );

The function read() is used with input streams, and reads num bytes from the stream before placing them in buffer. If EOF is encountered, read() stops, leaving however many bytes it put into buffer as they are. For example:

         struct {
           int height;
           int width;
         } rectangle;

         input_file.read( (char *)(&rectangle), sizeof(rectangle) );
         if( input_file.bad() ) {
           cerr << "Error reading data" << endl;
           exit( 0 );
         }

Related Topics: gcount, get, getline, write

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •