#include typedef struct { char naam[80]; int punten; } Deelnemer; typedef struct { Deelnemer speler[100]; int aantalSpelers; } Stand; int main(void) { Stand leesData(void); void printWinnaars(Stand); Stand s; s = leesData(); printWinnaars(s); getchar(); return 0; } void printWinnaars(Stand st) { if (st.aantalSpelers == 0) { printf("Er is geen winnaar.\n"); } else { int i, max; max = st.speler[0].punten; for (i = 1; i < st.aantalSpelers; i++) { if (st.speler[i].punten > max) { max = st.speler[i].punten; } } printf("De winnaar(s) is(zijn):\n"); for (i = 0; i < st.aantalSpelers; i++) { if (st.speler[i].punten == max) { printf("%s\n", st.speler[i].naam); } } } } Stand leesData(void) { Stand st; FILE* infile; st.aantalSpelers = 0; infile = fopen("stand.txt", "r"); if (infile == NULL) { printf("File stand.txt kan niet gelezen worden.\n"); } else { while (st.aantalSpelers < 100 && fscanf(infile, "%79s%d", st.speler[st.aantalSpelers].naam, &st.speler[st.aantalSpelers].punten) == 2) { st.aantalSpelers++; } fclose(infile); } return st; }