Dynamic Linked Lists and File Manipulation/assign5.c
StudentInfoPtr promptForStudentInfo() {
    
    StudentInfoPtr newStudentInfoPtr = NULL;    
    
    //If no space is available return
    if ((newStudentInfoPtr = malloc(sizeof(StudentInfo))) == NULL) {
        puts("Unable to allocate memory");
        return NULL;
    }
    
    //Reads student info
    {
        printf("%s", "Student ID (9 digits): ");
        scanf("%9s", newStudentInfoPtr->studentId);
        
        printf("%s", "Student first name (20 characters max): ");
        scanf("%20s", newStudentInfoPtr->firstName);
        
        printf("%s", "Student last name (25 characters max): ");
        scanf("%25s", newStudentInfoPtr->lastName);
        
        formatName(newStudentInfoPtr->firstName);
        formatName(newStudentInfoPtr->lastName);
        
        printf("%s", "How many courses is the student attending: ");
        scanf("%d", &newStudentInfoPtr->numOfAttentingCourses);
    }
    
    //Reads each course data
    for (int i = 0; i < newStudentInfoPtr->numOfAttentingCourses; i++) {
        printf("%s", "Enter course info as CODE NUMBER e.g MATH 101: ");
        scanf("%29s %d", newStudentInfoPtr->courseInfoArr[i].courseName, &(newStudentInfoPtr->courseInfoArr[i]).courseId);
        convertToUppercase(newStudentInfoPtr->courseInfoArr[i].courseName);
    }

    newStudentInfoPtr->next = NULL;
    
    return newStudentInfoPtr;
}
/*
    promptForStudentInfo: prompts the user for a students info and stores it in a struct
    output: a pointer to the struct in memory
*/
prompts the user for a students info and stores it in a struct
output: a pointer to the struct in memory
prompts the user for a students info and stores it in a struct output : a pointer to the struct in memory
StudentInfoPtr promptForStudentInfo() {
    StudentInfoPtr newStudentInfoPtr = NULL;    
    if ((newStudentInfoPtr = malloc(sizeof(StudentInfo))) == NULL) {
        puts("Unable to allocate memory");
        return NULL;
    }
    {
        printf("%s", "Student ID (9 digits): ");
        scanf("%9s", newStudentInfoPtr->studentId);
        printf("%s", "Student first name (20 characters max): ");
        scanf("%20s", newStudentInfoPtr->firstName);
        printf("%s", "Student last name (25 characters max): ");
        scanf("%25s", newStudentInfoPtr->lastName);
        formatName(newStudentInfoPtr->firstName);
        formatName(newStudentInfoPtr->lastName);
        printf("%s", "How many courses is the student attending: ");
        scanf("%d", &newStudentInfoPtr->numOfAttentingCourses);
    }
    for (int i = 0; i < newStudentInfoPtr->numOfAttentingCourses; i++) {
        printf("%s", "Enter course info as CODE NUMBER e.g MATH 101: ");
        scanf("%29s %d", newStudentInfoPtr->courseInfoArr[i].courseName, &(newStudentInfoPtr->courseInfoArr[i]).courseId);
        convertToUppercase(newStudentInfoPtr->courseInfoArr[i].courseName);
    }
    newStudentInfoPtr->next = NULL;
    return newStudentInfoPtr;
}
StudentInfoPtr promptForStudentInfo ( ) { StudentInfoPtr newStudentInfoPtr = NULL ; if ( ( newStudentInfoPtr = malloc ( sizeof ( StudentInfo ) ) ) == NULL ) { puts ( " " ) ; return NULL ; } { printf ( " " , " " ) ; scanf ( " " , newStudentInfoPtr -> studentId ) ; printf ( " " , " " ) ; scanf ( " " , newStudentInfoPtr -> firstName ) ; printf ( " " , " " ) ; scanf ( " " , newStudentInfoPtr -> lastName ) ; formatName ( newStudentInfoPtr -> firstName ) ; formatName ( newStudentInfoPtr -> lastName ) ; printf ( " " , " " ) ; scanf ( " " , & newStudentInfoPtr -> numOfAttentingCourses ) ; } for ( int i = 0 ; i < newStudentInfoPtr -> numOfAttentingCourses ; i ++ ) { printf ( " " , " " ) ; scanf ( " " , newStudentInfoPtr -> courseInfoArr [ i ] . courseName , & ( newStudentInfoPtr -> courseInfoArr [ i ] ) . courseId ) ; convertToUppercase ( newStudentInfoPtr -> courseInfoArr [ i ] . courseName ) ; } newStudentInfoPtr -> next = NULL ; return newStudentInfoPtr ; }
promptForStudentInfo: prompts the user for a students info and stores it in a struct
output: a pointer to the struct in memory
promptForStudentInfo : prompts the user for a students info and stores it in a struct output : a pointer to the struct in memory
//If no space is available return //Reads student info //Reads each course data