Code:
int results( char file[])
{
FILE *results;
char line[BUFSIZ];
if((results=fopen(file, "r")) ==NULL)
{
printf("Could not open file\n");
return EXIT_FAILURE;
}
while( fgets(line, sizeof line, results) !=NULL )
{
sscanf(line,"%s %i %i %s %i %i", team1, &goal1, &behind1, team2, &goal2, &behind2);
//printf("%s %i %i %s %i %i\n", team1, goal1, behind1, team2, goal2, behind2);
{
if(strcmp(teamnames[0],team1) == 0);
{
countgames++;
}
}
}
printf("games = %i\n", countgames);
fclose(results);
return EXIT_SUCCESS;
}
The count should be at no more than 12 when i call the printf function, however it says the count has reached 59. What exactly have i done wrong?