The function read_data()
accepts as input an input-file stream ins
and a character delimiter
.
When called, the function read_data()
reads all bytes in ins
from the
location of ins
's file pointer up to and including the first occurrence of
the character delimiter
. If delimiter
doesn't occur in ins
,
read_data()
reads up to the end-of-file.
read_data()
returns a pointer to a block of memory containing all the
bytes read from ins
and an integer giving the number of bytes in the
block.
Design an algorithm to implement the read_data()
function. You algorithm
should handle arbitrary amounts of data, handle all stream input errors, and
use memory efficiently ("efficiently" means that reading 10 bytes
should take significantly (orders of magnitude) less memory overall than
reading one million bytes).
This page last modified on 14 August 2001.