CSC 161 Grinnell College Fall, 2011
Imperative Problem Solving and Data Structures

Reading on Text Files


Many applications involve analysis of data found in a file (e.g., a spreadsheet or text-based documenbt). As an example, this reading outlines several approaches to the following problem.


File class-tests.dat shows test scores for a hypothertical class. The file is organized as follows:

A program is to be created to print scores for a designated test or the average test score for each person, according to a command-line parameter:

Approach 1: Read name into array and read scores with fprintf


Approach 2: Read full line at a time