printf("\nteste -> ");
scanf("%i", &opAjuda);
/ * opHelp is to receive an integer, but I want to do an if here, saying that if the person writes a character rather than integer, it goes to the help screen and shows the message that is inside the if. And then the person has to re-enter, in this case, an entire number. * /
if (opAjuda == 0) {
/*system("clear");
telaAjuda ();
printf("\n\tTENTE NOVAMENTE!\n");
printf("\n\tOBS: Digite um numero relacionado ao topico que deseja.\n");
subMenu_Ajuda();*/
//telaPrincipal ();
printf("\n%s", opAjuda); //teste pra ver o q estava imprimindo
} else {
//Aqui fica o meu switch case
}
When I type a numerical value, the program works fine, but when I type some character (other than the special ones I already have defined and already made the ifs for it) then when I type a character it is in an infinite loop .
It happens that when I did the test to see what I was printing when I typed a character it prints a NULL value, I tried to represent that value in if but I can not.
Can anyone help me?
I want to do this because I am thinking about the user, the program is written and has tips saying it is to type a number, but not all users follow what is written, and I want the program to be prepared should it happen.