Lecture 21: File Input/Output
Activity:
We saw in today's lecture the definition of a file and the C functions
associated with manipulating a file. Here's your opportunity to write
code that accesses and writes to a file. Given a text file called
text, copy this file, double-space it, and write to to a new file
called text_double. As always, it's important to follow
good design principles by stating the problem, describing the algorithm
that you'll use, and then write the C code. Since files are a new
concept, you may do all the processing in the main function.
Be sure to trace the code, checking for errors and mentally testing your
code. (Hint: To double space a file, recall that the '\n' character
prints a new line.)
Problem Specification:
The Algorithm:
The C Program: