Heyo. I've been bored at work and decided to brush up on my programming, but I'm hitting what appear to be a few pretty basic problems that I can't seem to fix. I'm trying to use an if statement to return different values depending on different values for passed character, ignoring case.
Here's how the function looks right now:
Code:
int CheckName(int x) {
if (x == 'Q' || x == 'q')
return -1;
else if (x == ('c' || 'b' || 'h' || 'k' || 'm'))
return 1;
else if (x == ('C' || 'B' || 'H' || 'K' || 'M'))
return 1;
else
return 0;
}
The first if check works fine, but everything fails the following if statements and ends up returning 0. I have also tried:
Code:
int CheckName(int x) {
if (x == 'Q' || x == 'q')
return -1;
else if (x == 'c' || 'b' || 'h' || 'k' || 'm')
return 1;
else if (x == 'C' || 'B' || 'H' || 'K' || 'M')
return 1;
else
return 0;
}
The only way I have gotten it to work is to have multiple checks within the parentheses, like the first if check, but it looks very large and overcomplicated. Is there a better way to do this?