Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are required to write an interactive C program that prompts the user for commands, accepts commands from the keyboard (stdin) and executes those commands.
You are required to write an interactive C program that prompts the user for commands, accepts commands from the keyboard (stdin) and executes those commands. When a command requires output, it must be written to stdout. The program must continue to accept and process commands until the user types the end command. The program deals with linked lists. Each node of such a list contains a string of length at most 255, a positive integer (i.e., an integer value 2z 1) and a pointer to the next node of the list. For any node, the string and the integer stored in that node will be referred to as the text and the index for that node respectively. Initially, the list is empty. At all times, the existing list must satisfy the following requirements: 1. The index is a number of the node in the list, i.e. the first node has index 1, and when the list is scanned from the beginning to the end, the value of indexes is increasing by 1 2. The texts appearing in the list are all distinct, that is, no two nodes have the same text. The commands and their interpretations are as follows. (You should bear in mind that different parts of a command are separated by one or more spaces.) Command Insert After: The syntax for this command is as follows: ina num str A. Here, ina represents the name of the command, num represents a positive integer number, and str represents a text. The interpretation of this command is as follows. (a) A new node with the text specified in the command must be inserted in the list after a node whose index is equal to the number specified in the command, indexes of the list should be changed to keep increasing order, and the following message must be printed "Ok" (b) If the list contains a node whose text is identical to the text specified in the command, then no exists new node must be created and the following message must be printed "Such text already (c) Ifthe list does not contain a node whose index is equal to the number specified in the command then a new node must be inserted at the end of the list and the following message must be printed "Text inserted at the end
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