Question.2
A UART command parser reads a line and compares it:
char cmd[16]; fgets(cmd, sizeof(cmd), uart_stream); if (strcmp(cmd, "READ") == 0) { execute_read(); }
The user sends READ followed by Enter. The comparison always fails. Why?
READ
Select Answer
fgets is not compatible with strcmp
fgets
strcmp
fgets includes the trailing newline character
strcmp is case-sensitive and the UART sends lowercase
cmd is too small to hold "READ"
cmd
"READ"