#include <stdio.h>
#include <stdlib.h>
struct student
{
char name[10];
int marks[4];
};
int main()
{
struct student s[5];
int i=0;
FILE *fp=fopen("Grades.txt","r");
if(fp==NULL)
{
printf("Error Opening the input file\n");
return-1;
}
else
printf("File Opening successfully\n");
while(!feof(fp))
{
fscanf(fp,"%s", s[i].name);
for(int j=0; j<4; j++)
fscanf(fp,"%d", &s[i].marks[j]);
i++;
}
printf("The Grade details ....\n");
for(int i=0; i<5; i++)
{
printf("%s\n",s[i].name);
for( int j=0; j<4; j++)
printf("%d\n", s[i].marks[j]);
}
fclose(fp);
return 0;
}
Peter 55 66 44 67 Lilly 100 90 43 89 John 34 56 78 65 Mary 45 56 78 90 Alex 30 45 65 54