Question
Commands are passed to the command line of a Linux terminal in the format $COMMAND,PARAMETER1,PARAMETER2,...,PARAMETER5 i.e., the command begins with the identifying '$' symbol,
Commands are passed to the command line of a Linux terminal in the format "\$COMMAND,PARAMETER1,PARAMETER2,...,PARAMETER5 "
i.e., the command begins with the identifying '$' symbol, followed by a command string, then a list of parameters separated by commas. A command can have up to 5 parameters, or no parameters. Parameters can be up to 5 characters in length. Commands end with a carriage return ' '.
Write a function void parse(char *input) that takes in Commands and parses them into a command string and an array of parameters.
For the following Commands, print the command string and parameters of each: 1. $GETNUM,1 2. $GETSUM,2,3 3. $LISTNUMS,10,300,-40 4. $DONOTHING
Expected outputs: 1. Command string = GETNUM Parameter[0]=1
2. Command string = GETSUM Parameter[0]=2 Parameter[1]=3
3. Command string = LISTNUMS Parameter[0]=10 Parameter[1]=300 Parameter[2]=-40
4. Command string = DONOTHING This command has no parameters
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