Question
C PROGRAM: LINKED LISTS typedef struct node_ { int data; struct node_* next; }node; node *insertathead(node *list, int data); Parameters: List: a pointer to the
C PROGRAM: LINKED LISTS
typedef struct node_ {
int data;
struct node_* next;
}node;
node *insertathead(node *list, int data);
Parameters:
List: a pointer to the head of a single linked list
Data: the number to be inserted into the head of the linked list
Return: the new head of the linked list
void print_list(node* list);
Parameters:
list: A pointer to the head of a single linked list
Return: none
See example output, prints out the linked list
void free_list(node* list);
Parameters
list: A pointer to a single linked list
Return: None
This function should free each node in the linked list
node* create_list(char* file);
Parameters:
file: The name of the input file
Return: The head of the linked list
This function will open the input file and will build a linked list using the insert_at_head() function using the contents of the file.
int main(int argc, char* argv[]);
Main will read in an input file as a command line argument and then create a linked list, print it out and then free it.
input.txt:
1
2
3
4
5
Sample output:
[jlz6w7@tc.rnet.missouri.edu ~]$ ./a.out input4.txt
5->4->3->2->1->NULL
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started