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
Get step-by-step solutions from verified subject matter experts
