Answered step by step
Verified Expert Solution
Link Copied!

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
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

Students also viewed these Databases questions

Question

Explain who developed concrete as a building material?

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago