Question: plese modify the given question according to the instruction Please Modify this code according to this instructions cmds . c Need to modify the Cmd

plese modify the given question according to the instruction Please Modify this code according to this instructions
cmds.c
Need to modify the Cmd struct to include:
ms and h
Add code in mem_display(), help(), mem_set() functions
Command routine calls with 2 arguments, e.g.
mem_display(Cmd *cp, char *arguments)
&cmds[0]
Address of the string 10000
If we enter a command md 10000 to display the contents of 16 locations starting with 10000, the arguments passed are:
file: cmds.c
/* the Makefile arranges that #include <..> searches in the right
places for these headers--200920*/
#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 stop(Cmd *cp, char *arguments);
PROTOTYPE int mem_display(Cmd *cp, char *arguments);
/* command table */
Cmd cmds[]={{"md", mem_display, "Memory display: MD "},
{"s", stop, "Stop" },
{NULL, NULL, NULL}}; /* null cmd to flag end of table */
char xyz =6; /* test global variable */
char *pxyz = &xyz; /* test pointer to xyz */
/*===================================================================*
* command routines
*
* Each command routine is called with 2 args, the remaining
* part of the line to parse and a pointer to the struct cmd for this
* command. Each returns 0 for continue or 1 for all-done.
*
*===================================================================*/
int stop(Cmd *cp, char *arguments)
{
return 1; /* all done flag */
}
/*===================================================================*
*
* mem_display: display contents of 16 bytes in hex
*
*/
int mem_display(Cmd *cp, char *arguments)
{
printf("Reached mem_display, passed argument string: |%s|
", arguments);
printf(" help message: %s
", cp->help);
return 0; /* not done */
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!