Before "talking" about my problem, first look at my code and ignore the accentuation errors in the console if it is to execute.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main(){
char nome[41];
printf("Texto: ");
fgets(nome, 40, stdin);
if (strcmp(nome, "0") == 0) {
printf("Sim. fgets está funcionando.\n");
} else {
printf("Não. fgets não está funcionado.\n");
}
printf("Texto: ");
gets(nome);
if (strcmp(nome, "0") == 0){
printf("Sim. gets está funcionando.\n");
} else {
printf("Não. gets não está funcionando.\n");
}
}
WhenItype"0" with the fgets command, the IF does not find "0", BUT when I type "0" through gets .
I want to avoid gets , as many websites / books recommend not to use this command, as it is dangerous and gives buffer error. (so far, I've had no buffer-related issues) but infezlimente fgets is not working as I wanted, only gets is working in my codes, but I want to avoid it.
Does anyone know how to make fgets have the characters detected by the