Unformatted I/O

Unformatted I/O

ostream &write(const char *src, int n)

write outputs the specified number of chars to a stream, from an array in memory:

ostream &write(const char *src, int n);

It inserts n characters from the array src into the stream.

istream &read(char *dst, int n)

read inputs the specified number of characters from a stream, into an array in memory:

istream &read(char *dst, int n);

int gcount()

gcount returns the number of characters read by the last unformatted input operation (get, getline, and read):

int gcount();

Example:

char buffer[80];
cin.read(buffer, sizeof(buffer));
cout << "read " << cin.gcount() 
     << " characters" << endl;
Index