Originally Posted by
RainbowStar
i can compile it but it doesn't work the way i want.
i wanted to make it so that when the program asks "Are you X or Y ? "
and i type in Y it will say "You are a male" and when i type X " You are a female".
so i thought when i make it like this it will work
Code:
if ( thisisacharacter == X) // it will say that about the female and
if ( thisisacharacter == Y) it will say that about male
but when i type any character or number it will cout only the first sentence.
i tried it like this now:
Code:
if ( thisisacharacter == "X"
but i didn't work
In the code you posted, the user is entering a value into a char, and you then compare the char to 2 uninitialized integers. That doesn't make sense, what you want to do is compare the char, to a constant like "X" or "Y".
So instead of doing this:
Code:
int X, Y;
char input;
std::cin >> input;
if(input == X)
std::cout << "Male";
if(input == Y)
std::cout << "Female";
You should be doing something like this:
Code:
char input;
std::cin >> input;
if(input == 'X')
std::cout << "Male";
if(input == 'Y')
std::cout << "Female";