Hello, i am having a problem with the strcmp function. It seems that it always returns 0 even when the two strings are different. This is a snippet of the code i am using:
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?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; }