A few of things:
- fputs() is for putting strings, you can't use it to output ints (like you are doing). Use printf() instead.
EG
>fputs(data[i].scores[x], stdout); is wrong
>printf("%d", data[i].scores[x]); is correct
>data[i].ID = (int) p;
>data [i].scores[x] = (int) p;
is wrong. p is a pointer. You need to do something like
>data[i].ID = atoi(p);
>data [i].scores[x] = atoi(p);
There, I think it works now. Have a go and see what you think.
Code:
Julie Adams 1234 52 7 100 78 34
Harry Smith 2134 90 36 90 77 30
Tuan Nguyen 3124 100 45 20 90 70
Jorge Gonzales 4532 11 17 81 32 77
Amanda Trapp 5678 20 12 45 78 34
Lou Mason 6134 34 80 55 78 78
Sarah Black 7874 60 100 56 78 45
Bryan Walljasper 8026 70 10 66 78 56
Ling Wong 9893 34 9 77 78 20
Bud Johnson 1947 45 40 88 78 55
Joe Giles 2877 55 50 99 78 55
Jim Nelson 3189 82 80 100 78 77
Paula Hung 4602 89 50 91 78 60
Ted Turner 5405 11 11 0 78 10
Evelyn Gilley 6999 0 98 89 78 20
Scores of data structures element 10: 55 50 99 78 55
Also, instead of using your errormsg function, you could use perror(). It'll tell you why the file cannot be accessed.