#include #include #include typedef struct Golfer { char fname[80]; char lname[80]; int handicap; } Golfer; int findBestGolfer(Golfer golfers[], int numGolfers); int main() { printf("Hello World!\n"); Golfer g; strcpy(g.fname,"Roger"); strcpy(g.lname,"Priebe"); g.handicap = 17; printf("%s, %s - %d\n",g.lname, g.fname, g.handicap); Golfer golfers[50]; FILE *fptr; fptr = fopen("golfers.dat", "r"); char buf[BUFSIZ]; int numGolfers = 0; if (fptr == NULL) { printf("Cannot open file!\n"); exit(0); } else { printf("found it!\n"); char fname[25]; char lname[25]; int handicap; while (fscanf(fptr, "%s %s %d", fname, lname, &handicap) != EOF) { strcpy(golfers[numGolfers].fname,fname); strcpy(golfers[numGolfers].lname,lname); golfers[numGolfers].handicap = handicap; numGolfers++; } } for (int i = 0; i < numGolfers; i++) printf("%s, %s - %d\n",golfers[i].lname, golfers[i].fname, golfers[i].handicap); int best = findBestGolfer(golfers, numGolfers); printf("the best is %s %s\n", golfers[best].fname, golfers[best].lname); } int findBestGolfer(Golfer golfers[], int numGolfers) { int best = 0; for (int i = 0; i < numGolfers; i++) { if (golfers[i].handicap < golfers[best].handicap) best = i; } return best; }