Reading Text Files in the
C Programming Language

prepared for:
Advanced C (COP2222)
Valencia Community College
Orlando, Florida

by:
Scott Brueckner

presented:
November 9, 1999

Please see the Acknowledgment of Error at the bottom of this page.

Introduction
Methodology
File Open Modes
File Read Functions
The Input Files
The Program
Program Output
Analysis
Recommendations

File Download
Send Questions or Comments

Scott's Home Page

Acknowledgment of Error

Several people have pointed out an error in the T_fread() function, to wit...

I use calloc() to allocate memory for a local variable, but do not explicitly release the memory with the free() function. This causes a memory leak because, although the variable is released at the end of the T_fread() function, the memory is not deallocated automatically.

To correct this, please add the line:

  free(cFile);

before the 'return' statements in T_fread().

I apologize for any inconvenience this has caused, along with any threat to national security, the environment, the price of gasoline, the spread of AIDS, global hunger, or the extinction of any species of animal, plant, or microorganism.