I'm supposed to create a program that reads in the name of a file, then takes the names of students, which are listed (last, first, m) and concatnate the first with the last (firstlast) and add .dat at the end for each student to open a file with and unknown number of grade for that student, and avg the grades together.
Then, I must list the class average, the maximum score, and the minimum score. I only have so much right now and I honeslty don't know if I'm even on the right track.
HELP???
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
FILE *inputfile, *infile;
double mark;
int grade;
int avg = 0.0;
int i = 0;
char student[30];
char filename[30];
char *first, *last, *middle;
printf ("Enter Name of Data File: \n");
scanf ("%s", filename);
inputfile = fopen( filename , "r");
while ((fscanf (inputfile, "%s", student) != EOF))
{
for (i = 0;i>=0;i++)
{
fscanf(inputfile, "%s %s %c", last, first, middle);
infile = fopen( strcat(first,last).dat, "r");
for (grade = 0; grade != 0; grade++)
{
fscanf (infile, "%d", &mark);
mark = mark + mark;
avg = mark/grade;
}
}
}
return 0;
}