I have to make a program where the input must be one of 2 values, 'M' or 'F'.
Here is the program segment that I have created to demonstrate
do
{
printf("What is your Gender? (M for Male - F for Female) ");
fgets(GenderValue, 16, stdin);
if (GenderValue[0] == '\n')
{
printf("Try again");
getch();
system("cls");
loop=1;
}
else
{
loop = -1;
}
if (GenderValue == "M");
{
loop =-1;
}
else if(GenderValue == "F");
{
loop=-1;
}
else
{
printf("Try again");
getch();
system("cls");
loop=1;
}
}
while(loop > 0); //Checks for NULL input
printf("Gender: %s",GenderValue);
I know I could have done an integer choice input, but I would like to recycle this later if possible.
So far the program calls my Gender value comparisons "Errors", Which is fine, except I have no idea what to do next, I could find a function that compares strings, but I really don't want to over complicate my code.
Edit: Duplicate?, Really?, The example given doesn't even come close to helping me.
Edit 2: Found the problem, i had ;'s next to my if statements, that's fixed now. But seriously, no one spotted this ?