#include <stdio.h>
#define TRUE 1
#define FALSE 0
typedef struct {
char student[30];
int q1;
int q2;
int q3;
int proj;
int mid;
int final;
int total;
} Record;
Record records[10];
FILE *ptin, *ptout;
int main(void)
{
int i, j, trash, flag = TRUE;
char line[90];
char header[90];
ptin = fopen("studentsmark.txt", "rt");
ptout = fopen("studentresult.txt", "wt");
if(ptin == NULL || ptout == NULL) {
printf("\nError opening files! \n");
return 1;
}
fgets(line, 88, ptin);
fgets(header, 88, ptin);
flag = TRUE;
i = 0;
while (flag > 0) {
flag = fscanf(ptin, "%d %s %d %d %d %d %d %d",&trash, records[i].student, &records[i].q1,
&records[i].q2, &records[i].q3, &records[i].proj, &records[i].mid, &records[i].final);
fprintf("\n%d %s %d %d %d %d %d %d\n", trash, records[i].student, records[i].q1, records[i].
q2,records[i].q3, records[i].proj, records[i].mid, records[i].final);
++i;
}
/*for(j = 0; j < i-1; j++) {
printf("\n%s %d %d %d %d %d %d\n", records[j].student, records[j].q1,records[j].q2,
records[j].q3, records[j].proj, records[j].mid, records[j].final);
}
for(i = 0; i < 10; i++) {
records[i].total = records[i].q1 + records[i].q2 + records[i].q3 + records[i].mid + records[i].final;
}*/
fclose(ptin);
fclose(ptout);
}
help plz my outputfile is empty


Sign In
Create Account


Back to top









