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; (char *)(&rectangle), sizeof(rectangle) );
     if( input_file.bad() ) {
       cerr << "Error reading data" << endl;
       exit( 0 );

Related Topics: gcount, get, getline, write