The ANSI C function control( ) below written for an embedded system must call run(), stop(),load() or dump() on the line shown, passing arg and retuning the return value of the called function back to the caller. Which of the following demonstrate correct syntaxes for the required call and return?
extern int load(int),dump(int), stop(int), run(int);
static struct command {
char key;
int(*op)(int);
}commands[]={
{'R', run },
{'S', stop},
{'L', load},
{'D', dump},
{'\0',0}
};
int control(char cmd, int arg)
{
struct command *c = commands;
do
if (c->key == cmd)
/* PLACE CALL THROUGH FUNCTION POINTER HERE */
while (c++->key != '\0');
return -1;
}
A. return *c->(op(arg));
B. return *c->op(arg);
C. return (*c->op)(arg);
D. return (*c)->op(arg);
E. return c->op(arg);
--
FROM 1.147.24.*