The structure that will be used in both of the programs will represent one team. It has fields for the school name, team name, score for game 1, score for game 2, and score for game 3.
1 2 3 4 5 6 7 8 9
|
struct teamInfo
{
char schoolName[20];
char teamName[20];
int game1Score;
int game2Score;
int game3Score;
};
|
The file consists of a set of multi-line records for the teams that participated in the tournament. Each record represents one team and each line for a record represents a piece of information for the team. The lines for each player are: the school name, the team name, the score for game 1, the score for game 2, and the score for game 3.
Takes a file called teams.txt that looks similar like
DELAWARE ST.
BLUE HENS
187
162
171
With more information that follows
Output
The output will be a file called binary_teams. It will contain a structure for each of the teams in the teams.txt file.
Suggested Logic for main()
Create a teamInfo variable, C-Style string, input file stream, and output file stream.
Open the file teams.txt for input and verify that it opened correctly
Open the file binary_teams for *binary* output and verify that it opened correctly
Use getline to read the school name from the input file into the C-Style string
While there are input records in the input file
Put the school name into the appropriate field of the teamInfo variable
Use getline to read the team name from the input file into the C-Style string
Put the team name into the appropriate field of the teamInfo variable
Use getline to read the score for game 1 from the input file into the C-Style string
Convert the C-style string to an integer value
Put the integer version of the score for game 1 into the appropriate field of the teamInfo variable
Use getline to read the score for game 2 from the input file into the C-Style string
Convert the C-style string to an integer value
Put the integer version of the score for game 2 into the appropriate field of the teamInfo variable
Use getline to read the score for game 3 from the input file into the C-Style string
Convert the C-style string to an integer value
Put the integer version of the score for game 3 into the appropriate field of the teamInfo variable
Write the teamInfo variable to the output file using the write command
Use getline to read the next school name from the input file into the C-Style string
Endwhile
Close the input and output files
I have no idea how to make write this, due to being sick and missing a class or two.