KNIFE JACK
1.3
6.0 5.1 6.3 5.9 6.5
WILLIAMSON FLIP A
1.4
3.5 4.1 4.7 7.2 3.8
SOMMER TODD
1.2
8.0 9.1 8.1 9.3 9.0
SWAN MIKE
1.1
4.3 2.1 9.9 6.2 7.0
The above is my txt file.
im trying to retrieve the data:
the first line is the name,
second line is the difficulty,
third line is the 5 scores
if necessary these are the pound defines used
#include <iostream>
#include <cstdlib>
#include <fstream>
#define MAX_DIVER 50
#define N_JUDGES 5
#define MAX_NAMELENGTH 20
/*
this function reads data from input file and calculates the total number of diver
pre: ifstream& fin, char name[MAX_DIVER], double score[N_JUDGES], double difficulty[MAX_DIVER]
post: int j
*/
int input(ifstream& fin, char name[MAX_DIVER], double score[N_JUDGES], double difficulty[MAX_DIVER])
{
int ch;
int i;
int j = 0;
do
{
for (i=0; i!='/0'; i++)
{
fin >> ch[i];// reading character by character
/*if(ch == EOF)
{
break;
}*/
name[i] = ch;//populating name array
}
getline(fin,difficulty[j]);// reading population difficulty level array
/** fin.ignore(); */
for (i = 0; i<N_JUDGES; i++)
{
fin >> score[i];//reading and population score array
fin.ignore(); //Ignore 1 space
}
j++;//calculating total number of divers
}while (!fin.eof());
return j;
}
I need help in figuring out how to obtain those 3 data (name,difficulty,and scores) and repeat the do-while loop until EOF.
Any help would be appreciated.