Question: Please complete the Student.c file below for adding a new student and deleting an existing student. /* Student.c: maintaining student records */ #include Student.h #include
Please complete the Student.c file below for adding a new student and deleting an existing student.
/* Student.c: maintaining student records */
#include "Student.h"
#include #include #include #include
/* allocate a new student record */ STUDENT *NewStudent(int ID, char *Name, char Grade) {
/* FIXME */
} /* end of NewStudent */
/* delete a student record */ void DeleteStudent(STUDENT *s) {
/* FIXME */
} /* end of DeleteStudent */
/* print a student record */ void PrintStudent(STUDENT *s) { assert(s); printf("Student ID: %d ", s->ID); printf("Student Name: %s ", s->Name); printf("Student Grade: %c ", s->Grade); } /* end of PrintStudent */
/* test the student record functions */ int main(void) { STUDENT *s1 = NULL, *s2 = NULL; printf("Creating 2 student records... "); s1 = NewStudent(1001, "Jane Doe", 'A'); s2 = NewStudent(1002, "John Doe", 'C');
printf("Printing the student records... "); PrintStudent(s1); PrintStudent(s2);
printf("Deleting the student records... "); DeleteStudent(s1); s1 = NULL; DeleteStudent(s2); s2 = NULL;
printf("Done. "); return 0; } /* end of main */
/* EOF */
The header file is
/* Student.h: header file for student records */
#ifndef STUDENT_H #define STUDENT_H
#define SLEN 40
struct Student { int ID; char Name[SLEN+1]; char Grade; }; typedef struct Student STUDENT;
/* allocate a new student record */ STUDENT *NewStudent(int ID, char *Name, char Grade);
/* delete a student record */ void DeleteStudent(STUDENT *s);
/* print a student record */ void PrintStudent(STUDENT *s);
#endif /* STUDENT_H */
/* EOF */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
