Strings and Structures/assign4.c
void processCourseRecord(char *record, CourseInfo *courseInfo){
    
    char *strTokPtr;
    int index = 1;  //the index of data in the record to be processed

    strTokPtr = strtok(record, ",");
    while(strTokPtr != NULL){
        
        switch(index){
            
            //processes the name of the course
            case COURSENAMEINDEX:{
                convertToUppercase(strTokPtr);
                strcpy(courseInfo->courseName, strTokPtr);
            }
            break;
            
            //processes the course code of the course along with SUBJECTINDEX, LEVELINDEX, and SECTIONINDEX
            //concats the three codes together
            case FACULTYINDEX:{
                sprintf(courseInfo->courseCode, "%02d", atoi(strTokPtr));
            }
            break;
            
            case SUBJECTINDEX:{
                char subjectCode[3];
                               
                sprintf(subjectCode, "%02d", atoi(strTokPtr));

                strcat(courseInfo->courseCode, subjectCode);
            }
            break;
            
            case LEVELINDEX:{
                strcat(courseInfo->courseCode, "-");

                char levelCode[4];
                               
                sprintf(levelCode, "%03d", atoi(strTokPtr));

                strcat(courseInfo->courseCode, levelCode);
            }
            break;
            
            case SECTIONINDEX:{
                strcat(courseInfo->courseCode, "-");

                char sectionCode[3];
                               
                sprintf(sectionCode, "%02d", atoi(strTokPtr));

                strcat(courseInfo->courseCode, sectionCode);
            }
            break;
            
            //process the term 
            case SEMESTERINDEX:{
                convertToUppercase(strTokPtr);
                sprintf(courseInfo->term, "%s", strTokPtr);
            }
            break;
            
            case YEARINDEX:{
                int year = atoi(strTokPtr);
                char temp[4];            
                sprintf(temp, "%d", year);
                strcat(courseInfo->term, temp);
            }
            break;
        }
                
        index++;
        
        strTokPtr = strtok(NULL, ",");
    }
}
/*
    processCourseRecord: formats data relating to a course into readable output
    input: the data to be formatted (record), a struct to save the data (courseInfo)
*/
formats data relating to a course into readable output
input: the data to be formatted (record), a struct to save the data (courseInfo)
formats data relating to a course into readable output input : the data to be formatted ( record ) a struct to save the data ( courseInfo )
void processCourseRecord(char *record, CourseInfo *courseInfo){
    char *strTokPtr;
    int index = 1;  
    strTokPtr = strtok(record, ",");
    while(strTokPtr != NULL){
        switch(index){
            case COURSENAMEINDEX:{
                convertToUppercase(strTokPtr);
                strcpy(courseInfo->courseName, strTokPtr);
            }
            break;
            case FACULTYINDEX:{
                sprintf(courseInfo->courseCode, "%02d", atoi(strTokPtr));
            }
            break;
            case SUBJECTINDEX:{
                char subjectCode[3];
                sprintf(subjectCode, "%02d", atoi(strTokPtr));
                strcat(courseInfo->courseCode, subjectCode);
            }
            break;
            case LEVELINDEX:{
                strcat(courseInfo->courseCode, "-");
                char levelCode[4];
                sprintf(levelCode, "%03d", atoi(strTokPtr));
                strcat(courseInfo->courseCode, levelCode);
            }
            break;
            case SECTIONINDEX:{
                strcat(courseInfo->courseCode, "-");
                char sectionCode[3];
                sprintf(sectionCode, "%02d", atoi(strTokPtr));
                strcat(courseInfo->courseCode, sectionCode);
            }
            break;
            case SEMESTERINDEX:{
                convertToUppercase(strTokPtr);
                sprintf(courseInfo->term, "%s", strTokPtr);
            }
            break;
            case YEARINDEX:{
                int year = atoi(strTokPtr);
                char temp[4];            
                sprintf(temp, "%d", year);
                strcat(courseInfo->term, temp);
            }
            break;
        }
        index++;
        strTokPtr = strtok(NULL, ",");
    }
}
void processCourseRecord ( char * record , CourseInfo * courseInfo ) { char * strTokPtr ; int index = 1 ; strTokPtr = strtok ( record , " " ) ; while ( strTokPtr != NULL ) { switch ( index ) { case COURSENAMEINDEX : { convertToUppercase ( strTokPtr ) ; strcpy ( courseInfo -> courseName , strTokPtr ) ; } break ; case FACULTYINDEX : { sprintf ( courseInfo -> courseCode , " " , atoi ( strTokPtr ) ) ; } break ; case SUBJECTINDEX : { char subjectCode [ 3 ] ; sprintf ( subjectCode , " " , atoi ( strTokPtr ) ) ; strcat ( courseInfo -> courseCode , subjectCode ) ; } break ; case LEVELINDEX : { strcat ( courseInfo -> courseCode , " " ) ; char levelCode [ 4 ] ; sprintf ( levelCode , " " , atoi ( strTokPtr ) ) ; strcat ( courseInfo -> courseCode , levelCode ) ; } break ; case SECTIONINDEX : { strcat ( courseInfo -> courseCode , " " ) ; char sectionCode [ 3 ] ; sprintf ( sectionCode , " " , atoi ( strTokPtr ) ) ; strcat ( courseInfo -> courseCode , sectionCode ) ; } break ; case SEMESTERINDEX : { convertToUppercase ( strTokPtr ) ; sprintf ( courseInfo -> term , " " , strTokPtr ) ; } break ; case YEARINDEX : { int year = atoi ( strTokPtr ) ; char temp [ 4 ] ; sprintf ( temp , " " , year ) ; strcat ( courseInfo -> term , temp ) ; } break ; } index ++ ; strTokPtr = strtok ( NULL , " " ) ; } }
processCourseRecord: formats data relating to a course into readable output
input: the data to be formatted (record), a struct to save the data (courseInfo)
processCourseRecord : formats data relating to a course into readable output input : the data to be formatted ( record ) a struct to save the data ( courseInfo )
//the index of data in the record to be processed //processes the name of the course //processes the course code of the course along with SUBJECTINDEX, LEVELINDEX, and SECTIONINDEX //concats the three codes together //process the term 