[Solved] Parsing input data from a text file [closed]
#include <stdio.h> #include <stdlib.h> struct classes { char name[20]; char department[5];//+1 for ‘\0’ int course_number; }; int main(void){ FILE *file; char buffer[50]; struct classes student, students[48]; int i, count=0; file = fopen(“inputfile.txt”, “r”); while (fgets(buffer, sizeof(buffer), file)){ //Format : NAME is enrolled in DEPARTMENT NUMBER. if(3 == sscanf(buffer, “%19s %*s %*s %*s %4s %d”, student.name, … Read more