Assignment Description: In this assignment, you will build a program that dynamically manages memory on the heap. Specifically, you will read student information from a file, populate each student as a record in a linked list, and clean up heap memory before terminating.

Learning Objectives: This assignment connects to the following course goals:

  • Course Goal #5: Improve problem-solving and programming competency by building ever complex programs, specifically through analyzing, designing, implementing, testing and debugging C programs using various data types, loops, branches, arrays, and structs.
  • Course Goal #6: Write programs that manage memory using dynamic memory allocation functions and variables that contain a memory address (pointers). Apply these skills to allocate memory at run-time, and to (a) increase performance by passing addresses to functions instead of copying data, and (b) return more than one value from a function.

Starter Code: The following files are provided for you in this tarball

  • students.h : Defines a student structure and function prototypes
  • students.c : Functions are defined in this file, but not implemented
  • test.data : Contains some sample test data
  • Makefile : For compiling the program

YOUR TASK is to implement the following functions (found in student.h header file):

  • Student *buildStudentList()
    • Creates the entire linked list from the file. Should call readNext and push functions. Return is the head of the linked list
  • Student *makeStudent(char name[16], int age, double gpa);
    • Creates a student structure on the heap based on input parameters
  • Student *readNext();
    • Reads the next line from standard input and creates a student structure on the heap
  • void push(Student *student);
    • Pushes a new student node to the head of the linked list
  • void insert(Student *list, Student *s, int position);
    • Inserts a new student node in a specific position in the linked list
  • DisplayAll()
    • Displays the entire contents of the linked list
  • CleanUp()
    • Frees all memory that remains on the heap before the program terminates

Be Careful! The purpose of this assignment is to make sure you know how to dynamically manage memory and use pointers appropriately. Therefore.

  • Do not edit the main method (except for testing)
  • Do not change the function prototypes to get your code to work.
  • Do not create any new global variables

Test Cases: If you implemented your assignment correctly, you should get the following results. Make sure that you are not violating the conditions above when testing your assignment. We will be checking your code and ensure that it is following those rules when grading. see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.