write a C program about linkedlist

write a C program about linkedlist

Write a program list that maintains and manipulates a linked list of integers according to instructions provided in a file. list takes a single argument, which is the path to a file containing the instructions. If the file does not exist, your program must print “error” and nothing else.

list maintains a linked list containing zero or more integers, ordered from least to greatest. list will need to allocate space for new nodes as they are created using malloc; any allocated space should be deallocated using free before list terminates.

It supports two operations on this list:
insert n Adds an integer n to the list. If n is already present in the list, it does nothing. The instruction

format is an i followed by a space and an integer n.
delete n Removes an integer n from the list. If n is not present in the list, it does nothing. The instruction

format is a d followed by a space and an integer n.

Input format Each line of the input file contains an instruction. Each line begins with a letter (either “i” or “d”), followed by a space, and then an integer. A line beginning with “i” indicates that the integer should be inserted into the list. A line beginning with “d” indicates that the integer should be deleted from the list.

Output format Normal output for list is written on two lines. The first line is an integer indicating the length of the linked list after all instructions are performed. The second line is zero or more integers separated by spaces indicating the content of the linked list.

If the file given on the command line does not exist, list should print error and nothing else.

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper