Dynamic Linked Lists and File Manipulation/assign5.c
void deleteStudent(StudentInfoPtr *head, const char *studentId) {

    StudentInfoPtr currentStudentInfoPtr = *head;
    StudentInfoPtr previousStudentInfoPtr = NULL;
    
    if(!strcmp(currentStudentInfoPtr->studentId, studentId)){
        StudentInfoPtr hold = currentStudentInfoPtr;
        *head = currentStudentInfoPtr->next;
        free(hold);
    }
    else {  
        
        previousStudentInfoPtr = currentStudentInfoPtr;
        currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next;        
        
        while(currentStudentInfoPtr != NULL) {
            if(!strcmp(currentStudentInfoPtr->studentId, studentId)) {
                break;
            }  
            
            previousStudentInfoPtr = currentStudentInfoPtr;
            currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next;     
        }  
        
        StudentInfoPtr hold = currentStudentInfoPtr;
        previousStudentInfoPtr->next = currentStudentInfoPtr->next;
        currentStudentInfoPtr = currentStudentInfoPtr->next;
        free(hold);
    }
}
/*
    deleteStudent: deletes a student from the linked list by id
    input: the beginning of the linked list (head), the id to be deleted (studentId)
    output:
*/
deletes a student from the linked list by id
input: the beginning of the linked list (head), the id to be deleted (studentId)
output.
deletes a student from the linked list by id input : the beginning of the linked list ( head ) the id to be deleted ( studentId ) output .
void deleteStudent(StudentInfoPtr *head, const char *studentId) {
    StudentInfoPtr currentStudentInfoPtr = *head;
    StudentInfoPtr previousStudentInfoPtr = NULL;
    if(!strcmp(currentStudentInfoPtr->studentId, studentId)){
        StudentInfoPtr hold = currentStudentInfoPtr;
        *head = currentStudentInfoPtr->next;
        free(hold);
    }
    else {  
        previousStudentInfoPtr = currentStudentInfoPtr;
        currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next;        
        while(currentStudentInfoPtr != NULL) {
            if(!strcmp(currentStudentInfoPtr->studentId, studentId)) {
                break;
            }  
            previousStudentInfoPtr = currentStudentInfoPtr;
            currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next;     
        }  
        StudentInfoPtr hold = currentStudentInfoPtr;
        previousStudentInfoPtr->next = currentStudentInfoPtr->next;
        currentStudentInfoPtr = currentStudentInfoPtr->next;
        free(hold);
    }
}
void deleteStudent ( StudentInfoPtr * head , const char * studentId ) { StudentInfoPtr currentStudentInfoPtr = * head ; StudentInfoPtr previousStudentInfoPtr = NULL ; if ( ! strcmp ( currentStudentInfoPtr -> studentId , studentId ) ) { StudentInfoPtr hold = currentStudentInfoPtr ; * head = currentStudentInfoPtr -> next ; free ( hold ) ; } else { previousStudentInfoPtr = currentStudentInfoPtr ; currentStudentInfoPtr = ( StudentInfoPtr ) currentStudentInfoPtr -> next ; while ( currentStudentInfoPtr != NULL ) { if ( ! strcmp ( currentStudentInfoPtr -> studentId , studentId ) ) { break ; } previousStudentInfoPtr = currentStudentInfoPtr ; currentStudentInfoPtr = ( StudentInfoPtr ) currentStudentInfoPtr -> next ; } StudentInfoPtr hold = currentStudentInfoPtr ; previousStudentInfoPtr -> next = currentStudentInfoPtr -> next ; currentStudentInfoPtr = currentStudentInfoPtr -> next ; free ( hold ) ; } }
deleteStudent: deletes a student from the linked list by id
input: the beginning of the linked list (head), the id to be deleted (studentId)
output:
deleteStudent : deletes a student from the linked list by id input : the beginning of the linked list ( head ) the id to be deleted ( studentId ) output :