Commands are passed to the command line of a Linux terminal in the format "\$COMMAND,PARAMETER1,PARAMETER2,...,PARAMETER5\r" 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 '\r'. 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\r 2. $GETSUM,2,3\r 3. $LISTNUMS,10,300,-40\r 4. $DONOTHING\r 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

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter7: String Manipulation
Section: Chapter Questions
Problem 10E
icon
Related questions
Question

Commands are passed to the command line of a Linux terminal in the format "\$COMMAND,PARAMETER1,PARAMETER2,...,PARAMETER5\r"

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 '\r'.

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\r
2. $GETSUM,2,3\r
3. $LISTNUMS,10,300,-40\r
4. $DONOTHING\r

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

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT