I need help creating a C program function. The prototype is void print(struct node *list). This function will print the nodes in the linked list "list".
This is how the struct node is set up:
struct node
{
int data;
struct node *next;
};
Where data is the integer actually stored in the list and next is the memory location of the next element, or NULL for the end of the list.
To add a number to the list, create a new node, search the list for the proper point to insert the new node, adjust the prior node's "next" field to point to the new node, and adjust the new node's "next" field accordingly.
Similar actions are taken for printing, searching, and deleting.
You should use malloc(sizeof(struct node)) to get the address of a new node, and free(ptr) to release a node from memory (after deleting it, or at the end of the program).
Thanks in advance! Please let me know if you need any additional information.