0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
struct cmd1 {
char cmd[20];
};
struct cmd1 cmdd;
char cmd_ti[3] = "ti";
char cmd_tela1[2] = "a";
printf("\nTeste -> ");
fgets(cmdd.cmd, 20, stdin); //O que foi digitado pelo usuario
__fpurge(stdin);
printf("\nDigitado pelo usuario: %s", cmdd.cmd); //teste pra ver o que ta imprimindo
printf("\ncmd_ti: %s", cmd_ti); //teste pra ver o que ta imprimindo
printf("\ncmd_t1: %s", cmd_tela1); //teste pra ver o que ta imprimindo
if (strcmp(cmd_ti, cmdd.cmd) == 0) {
printf("\nOK");
printf("\n%s == %s", cmd_ti, cmdd.cmd);
} else {
printf("\nNOT OK");
printf("\n%s != %s", cmd_ti, cmdd.cmd);
}
return(0);
}
I need "you" to equal "you" in comparison. I’ve searched a lot of places, and I still can’t figure out what’s going on. Does anyone know how to help me because when I type you it doesn’t compare to the variable I’ve already left declared as you?
I understood where the mistake is now, but I still do not understand what I can do to take the enter. You could help me?
– Marcielli Oliveira
The above code removes enter - update your browser (F5) and you will see.
– carlosfigueira
Ah, I get it. Thank you. ;)
– Marcielli Oliveira