Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please modify a code in c programming language Please Modify this code according to this instructions cmds . c Need to modify the Cmd struct
please modify a code in c programming language
Please Modify this code according to this instructions
cmdsc
Need to modify the Cmd struct to include:
ms and h
Add code in memdisplay help memset functions
Command routine calls with arguments, eg
memdisplayCmd cp char arguments
&cmds
Address of the string
If we enter a command md to display the contents of locations starting with the arguments passed are:
file:
cmdsc
the Makefile arranges that #include searches in the right places for these headers
#include #include "slex.h Command table for tutor program an array of structures of type cmd for each command provide the token, the function to call when that token is found, and the help message.
slex.h contains the typdef for struct cmd and declares the cmds array as extern to all the other parts of the program.
Code in slex.c parses user input command line and calls the requested semantic action, passing a pointer to the cmd struct and any arguments the user may have entered.
PROTOTYPE int stopCmd cp char arguments; PROTOTYPE int memdisplayCmd cp char arguments;
command table
Cmd cmdsmd memdisplay, "Memory display: MD s stop, Stop" NULL NULL, NULL; null cmd to flag end of table
char xyz ; test global variable char pxyz &xyz; test pointer to xyz command routines Each command routine is called with args, the remaining part of the line to parse and a pointer to the struct cmd for this
command. Each returns for continue or for alldone.
int stopCmd cp char arguments return ; all done flag
memdisplay: display contents of bytes in hex
int memdisplayCmd cp char arguments printfReached memdisplay, passed argument string: s
arguments; printf help message: s
cphelp; return ; not done
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