Question: Explain and fix the logical flow bug within the switch statement. (What happens when the -h option is used?) while (*argv != NULL) { if

Explain and fix the logical flow bug within the switch statement. (What happens when the -h option is used?)

while (*argv != NULL) {

if (**argv == '-') {

switch ((*argv)[1]) {

case 'h':

printHelp(prog_name);

default:

printf("%s: Invalid option %s. Use -h for help. ",

prog_name, *argv);

}

} else {

if (entryCount < LENGTH(entries)) {

entries[entryCount].word = *argv;

entries[entryCount++].counter = 0;

}

}

argv++;

}

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!