1 2 3 4 5 6 7 8 9

*

*

*

*

But it we want to copy a text file exactly the way it is, including the whitespace characters this approach doesn't work
The istream call defines a get function that handles this problem, there are two versions of this function
The
get(char&)version reads a single character from the istream and places it in its parameter. This function returns NULLupon end-of-file. The other version of this function has the following declaration:

get(char* p, int n, char = '\n');

This procedure reads one or more characters into the buffer pointed to by p *The parameter n gives the size of the buffer. Note getwill always
terminate the character string that is read with a '\0', so there is room for
at most n-1 characters in this buffer
*The get operation terminates when eitheran end of file is encountered, or
n-1 characters have been read, orthe character that is passed as the third
parameter (
the terminating character) is encountered
*This terminating character isn't placed in p, and isn't read by the get
operation. To determine if get has overflowed the buffer, you must examine
the input stream to see if terminating character is up next.

#include <strstream.h> #include <iostream.h> #include <fstream.h>

// useful for read/write arrays // cin and cout -- also cerr // reading/writing files

23 March, 1998

Page 3