1
printf("\nteste -> ");
scanf("%i", &opAjuda);
/* opAhelp is to receive a whole, but I want to do an if here, saying that if a person writes a character instead of the whole one, it goes to the screen helps and shows the message that is inside the if. And then one has to type again, in 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 numeric value, the program works fine, but when I type some character (other than the special ones I’ve already defined and I’ve already made the ifs for it) then when I type a character it is in an infinite loop. When I did the test to see what I was printing when I typed a character it prints a NULL (null) value, I tried to represent this value in if but I’m not getting it. Can someone help me?
NOTE: I want to do this because I’m 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 if it happens.
Thank you Skywalker ;) I get it, I’ll try it this way. Cool, I’ll look it up on the linux terminal. Very interesting.
– Marcielli Oliveira