Develop an algorithm that accepts as input the name of a file, and computes the following statistics about the file:
'\n'
) including the ending newline but not the starting one. The
first line in the file doesn't have a starting newline, but the last line in
the file must have an ending newline, otherwise it isn't a line.
Your algorithm should detect and handle all possible errors; printing a meaningful error message and exiting are good enough for this problem. You should describe your algorithm in enough detail to indicate you understand the important issues involved with using file-stream I-O.
You can use pseudo-code as long as it has a direct relation to C++ constructs
(for example, using check eof
instead of ins.eof()
); when in doubt,
write in C++. You should describe your algorithm in enough detail so that
someone reading your description will be able to easily
This page last modified on 24 July 2001.