rendered paste bodywhile (option != 'n') {
printf("\nType in the match results in the following format: \"Chelsea 2 - 3 Arsenal\"\n");
fgets(line, sizeof line, stdin);
sscanf(line, "%s%d%c%d%s", team1, &score1, &hyphen, &score2, team2);
printf("\nDo you wish to enter more results? (y/n): ");
fgets(line, sizeof line, stdin);
sscanf(line, "%c", &option); // or option = line[0]
}
for (count = 0; count < numTeams; count++) {
if (strcmp(theLeague[count].name,team1) == 0) {
printf("\nTeam %s was found", team1);
theLeague[count].gamesPlayed++;
theLeague[count].goalsScored = theLeague[count].goalsScored + score1;
theLeague[count].goalsConceded = theLeague[count].goalsConceded + score2;
if (score1 > score2) {
theLeague[count].gamesWon++;
}
else if (score1 < score2) {
theLeague[count].gamesLost++;
}
else if (score1 == score2) {
theLeague[count].gamesDrawn++;
}
}
else {
printf("\nTeam not found\n");
}
}
for (count = 0; count < numTeams; count++) {
if (strcmp(theLeague[count].name,team2) == 0) {
printf("\nTeam %s was found\n", team2);
theLeague[count].gamesPlayed++;
theLeague[count].goalsScored = theLeague[count].goalsScored + score2;
theLeague[count].goalsConceded = theLeague[count].goalsConceded + score1;
if (score1 == score2) {
theLeague[count].gamesDrawn++;
}
else if (score1 < score2) {
theLeague[count].gamesWon++;
}
else if (score1 > score2) {
theLeague[count].gamesLost++;
}
}
else {
printf("\nTeam was not found\n");
}
}