if the arrangement of every student account in the file is like this...
STUDENT NUMBER \t NAME \t BIRTHDATE \t COURSE
i.e...
how can i transfer these info accordingly to an array of struct like this?...stud_num0 name0 bday0 course0
stud_num1 name1 bday1 course1
stud_num2 name2 bday2 course2
i have something like...Code:typedef struct student_profile{ long long int stud_num; char name[50]; char bday[50]; char course[50]; } STUDENT; .... STUDENT array[20];
thanks in advance!Code:void read_from_file(FILE *file, STUDENT array[20]) { int i; file = fopen("Students.txt", "r"); for(i = 0; !feof(file) && i < 20; i++) { fscanf(file, "%lld %s %s %s", &array[i].stud_num, array[i].name, array[i].bday, array[i].course); } fclose(file); }



LinkBack URL
About LinkBacks




