Dynamic Linked Lists and File Manipulation/assign5.c
void displayStudentInfo(StudentInfoPtr *head, int FLAG, StudentInfoPtr studentInfoPtr) {
    
    StudentInfoPtr currentStudentInfoPtr = NULL;
    
    switch(FLAG) {
        
        case(FLAG_DISP_ALL): {
            currentStudentInfoPtr = *head;
        }
        break;
        
        case(FLAG_DISP): {
            if(studentInfoPtr != NULL) {
                StudentInfo studentInfoCopy = *studentInfoPtr;
                currentStudentInfoPtr = &studentInfoCopy;
                currentStudentInfoPtr->next = NULL;
            }
        }
        break;
    }
    
    if(currentStudentInfoPtr == NULL) puts("No data!");
    
    int count = 1;
            
            //Prints each student info
            while (currentStudentInfoPtr != NULL) {
                puts("");
                printf("%s %d\n", "Student: ", count++);
                printf("%s\n", currentStudentInfoPtr->studentId);   
                printf("%s\n", currentStudentInfoPtr->firstName);   
                printf("%s\n", currentStudentInfoPtr->lastName);    
                printf("%d\n", currentStudentInfoPtr->numOfAttentingCourses);    

                for (int i = 0; i < currentStudentInfoPtr->numOfAttentingCourses; i++) {
                    printf("%s %d\n", currentStudentInfoPtr->courseInfoArr[i].courseName, currentStudentInfoPtr->courseInfoArr[i].courseId);
                }
                
                currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next;
            }
}
/*
    displayStudentInfo: displays each student information in a linked list
    input: the beginning of the linked list (head)
*/
displays each student information in a linked list
input: the beginning of the linked list (head)
displays each student information in a linked list input : the beginning of the linked list ( head )
void displayStudentInfo(StudentInfoPtr *head, int FLAG, StudentInfoPtr studentInfoPtr) {
    StudentInfoPtr currentStudentInfoPtr = NULL;
    switch(FLAG) {
        case(FLAG_DISP_ALL): {
            currentStudentInfoPtr = *head;
        }
        break;
        case(FLAG_DISP): {
            if(studentInfoPtr != NULL) {
                StudentInfo studentInfoCopy = *studentInfoPtr;
                currentStudentInfoPtr = &studentInfoCopy;
                currentStudentInfoPtr->next = NULL;
            }
        }
        break;
    }
    if(currentStudentInfoPtr == NULL) puts("No data!");
    int count = 1;
            while (currentStudentInfoPtr != NULL) {
                puts("");
                printf("%s %d\n", "Student: ", count++);
                printf("%s\n", currentStudentInfoPtr->studentId);   
                printf("%s\n", currentStudentInfoPtr->firstName);   
                printf("%s\n", currentStudentInfoPtr->lastName);    
                printf("%d\n", currentStudentInfoPtr->numOfAttentingCourses);    
                for (int i = 0; i < currentStudentInfoPtr->numOfAttentingCourses; i++) {
                    printf("%s %d\n", currentStudentInfoPtr->courseInfoArr[i].courseName, currentStudentInfoPtr->courseInfoArr[i].courseId);
                }
                currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next;
            }
}
void displayStudentInfo ( StudentInfoPtr * head , int FLAG , StudentInfoPtr studentInfoPtr ) { StudentInfoPtr currentStudentInfoPtr = NULL ; switch ( FLAG ) { case ( FLAG_DISP_ALL ) : { currentStudentInfoPtr = * head ; } break ; case ( FLAG_DISP ) : { if ( studentInfoPtr != NULL ) { StudentInfo studentInfoCopy = * studentInfoPtr ; currentStudentInfoPtr = & studentInfoCopy ; currentStudentInfoPtr -> next = NULL ; } } break ; } if ( currentStudentInfoPtr == NULL ) puts ( " " ) ; int count = 1 ; while ( currentStudentInfoPtr != NULL ) { puts ( " " ) ; printf ( " \n " , " " , count ++ ) ; printf ( " \n " , currentStudentInfoPtr -> studentId ) ; printf ( " \n " , currentStudentInfoPtr -> firstName ) ; printf ( " \n " , currentStudentInfoPtr -> lastName ) ; printf ( " \n " , currentStudentInfoPtr -> numOfAttentingCourses ) ; for ( int i = 0 ; i < currentStudentInfoPtr -> numOfAttentingCourses ; i ++ ) { printf ( " \n " , currentStudentInfoPtr -> courseInfoArr [ i ] . courseName , currentStudentInfoPtr -> courseInfoArr [ i ] . courseId ) ; } currentStudentInfoPtr = ( StudentInfoPtr ) currentStudentInfoPtr -> next ; } }
displayStudentInfo: displays each student information in a linked list
input: the beginning of the linked list (head)
displayStudentInfo : displays each student information in a linked list input : the beginning of the linked list ( head )
//Prints each student info