Description
Given a simple linked list defined as:
struct node { int data;
sruct node *next; };
Implement the following functions:
int Length(struct node* head);
Returns the number of nodes in the list.
void PrintList(struct node* head);
Prints all the nodes on a list
void Add(struct node** headRef, int new);
Given an int and a reference to the head pointer (i.e. a struct node** pointer to the head pointer), add a new node at the head of the list.
int Delete(struct node** headRef);
Takes a non-empty list, deletes the head node, and returns the head node’s data. void ZeroList(struct node** headRef);
Deallocates all of its memory and sets its head pointer to NULL (the empty list).
Write a small program in C to test all your functions. Your program should present a command line interface to the user. The following commands are valid:
a(dd) {x } = add a new node with value x to the list, at the front of the list d(el) = delete the fist node of list l(ength ) = print the number of nodes in the list p(rint) = print the complete list z(ero) = delete the entire list e(xit) = quit the program
Use fscanf( ) instead of scanf( )
05_CST8234_List – v 1 – 1 / 1
Reviews
There are no reviews yet.