Back to DFS's C Page


OAC Problem Set VIII

Structures

You are to write a program which reads the data in the pirates.dat file into an array of structures. Please take note of all data in the file. It is left to you to determine the data types required for the structures.

The information in the file is for five of the players from the 1960 World Series Champion Pittsburgh Pirates baseball team.

For each of the players you are to calculate his batting average and store it in the structure as a float.

You are then to print out a labeled table identical to the following.

                    1960 Pittsburgh Pirates
Player            Bats Throws Pos  AB   HR   Hits   Avg 
Roberto Clemente  R    R      OF   570  16   179   .314
Bill Mazeroski    R    R      2B   539  11   147   .273
Dick Groat        R    R      SS   572   2   186   .325
Smoky Burgess     L    R      C    337   7    99   .294
Dick Stuart       R    R      1B   438  23   114   .260

N.B. There is no leading zero to be printed for the batting average. You will need to use sprintf() to convert the float to a string that you can then alter for printing. Check the man page to see how to use it.

Before you start writing your code, prepare pseudocode and show it to your teacher for approval.

Things to be aware of:


Created 20 Feb 00
© DFStermole 2000