Strings and Structures/assign4.c
int loadCourseInfo(CourseInfo *courses){
    
    FILE *filePtr = NULL;
    char fileName[50];

    char courseRecordBuffer[MAX_LINE_LENGTH];
    int courseCount = 0;
    
    printf("%s", "Enter file to load courses from: ");
    scanf("%s", fileName);
    
    if((filePtr = fopen(fileName, "r")) == NULL) puts("Unable to open file. Exiting...");
    else{
        while(fgets(courseRecordBuffer, MAX_LINE_LENGTH, filePtr) != NULL){
            addCourseInfo(courses, &courseCount, courseRecordBuffer);
        }
        fclose(filePtr);
    }
        
    return courseCount;
}
/*
    loadCourseInfo: reads data relating to courses from a csv and stores it in an array of CourseInfo
    input: the array to store the data (courses)
    output: the number of records read/ number of courses (courseCount)
*/
reads data relating to courses from a csv and stores it in an array of CourseInfo
input: the array to store the data (courses)
output: the number of records read/ number of courses (courseCount)
reads data relating to courses from a csv and stores it in an array of CourseInfo input : the array to store the data ( courses ) output : the number of records read / number of courses ( courseCount )
int loadCourseInfo(CourseInfo *courses){
    FILE *filePtr = NULL;
    char fileName[50];
    char courseRecordBuffer[MAX_LINE_LENGTH];
    int courseCount = 0;
    printf("%s", "Enter file to load courses from: ");
    scanf("%s", fileName);
    if((filePtr = fopen(fileName, "r")) == NULL) puts("Unable to open file. Exiting...");
    else{
        while(fgets(courseRecordBuffer, MAX_LINE_LENGTH, filePtr) != NULL){
            addCourseInfo(courses, &courseCount, courseRecordBuffer);
        }
        fclose(filePtr);
    }
    return courseCount;
}
int loadCourseInfo ( CourseInfo * courses ) { FILE * filePtr = NULL ; char fileName [ 50 ] ; char courseRecordBuffer [ MAX_LINE_LENGTH ] ; int courseCount = 0 ; printf ( " " , " " ) ; scanf ( " " , fileName ) ; if ( ( filePtr = fopen ( fileName , " " ) ) == NULL ) puts ( " " ) ; else { while ( fgets ( courseRecordBuffer , MAX_LINE_LENGTH , filePtr ) != NULL ) { addCourseInfo ( courses , & courseCount , courseRecordBuffer ) ; } fclose ( filePtr ) ; } return courseCount ; }
loadCourseInfo: reads data relating to courses from a csv and stores it in an array of CourseInfo
input: the array to store the data (courses)
output: the number of records read/ number of courses (courseCount)
loadCourseInfo : reads data relating to courses from a csv and stores it in an array of CourseInfo input : the array to store the data ( courses ) output : the number of records read / number of courses ( courseCount )