I'm trying to get some ideas how to check for errors or mistypes in my data file. The errors are made by me, intentionally.
My file looks like this
Name HouseNr City Country number(how many sports) Sport1 Sport2 SportN
Carl Lincoln42 Houston USA 2 Basketball Football
while(fscanf(fData, "%s %s %s %s %d", (person + i)->name,
(person + i)->adr.houseNr, (person + i)->adr.city, (huvi + i)->adr.country,
&(sport + i)->sportCount) == 5)
{
for (j = 0; j < (person + i)->sportCount; j++)
{
fscanf(fData, "%s", (person + i)->sportName[j]);
}
i++;
}
Now what I don't grasp is, how should I check for errors in that file.
Let's assume that number
's value is higher than that of the SportN
.
This would mean that it scans other person's details as SportName
How should I tackle this? Change some code (please, some suggestions) or change the way I store my data?