The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
int main(void) {
const char *cmd = "start";
switch (cmd) {
case "start": puts("starting"); break;
case "stop": puts("stopping"); break;
}
return 0;
}
C cannot switch on strings. Use if (strcmp(cmd, "start") == 0) … else if …, or convert the string to an enum value first and switch on that.