0
I wanted a help in solving the problem of a string, because when you read the program automatically from as invalid option any option, so you do not use the option I chose. No if
I’ve tried with &&
instead of ||
and also did not give.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char sexo[2];
printf("---Sexo---\n");
printf("1 - Masculino\n");
printf("2 - Feminino\n");
setbuf(stdin, NULL);
fgets(sexo,2,stdin);
if(sexo[2]!='1' || sexo[2]!='2')
{
printf("\nOpção Inválida\n");
system("PAUSE");
sexo[2]=0;
}
return 0;
}
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site
– Maniero