I personally like to handle long IF statements by using the cascading property of switch/case:
Code:
char c;
cout << "Enter Choice";
cin >> c;
switch(toupper(c))
{
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'X': do something;
default : else do something;
}
--Or you can try this--
When you have a list of consecutive characters, you could just use a range of ascii values.. instead of looking for specific characters.
I'm not totally positive on how to do this in c++.. so someone please back me up on this
Code:
//IF c is between the ascii value of A and below the ascii value of I OR c equals the ascii value of X
if ((c >= 41h && c <=49h) || (c == 58h))
Which I think can also be written like this:
Code:
if ((c>='A' && c<='I') || (c=='X'))
which is much easier to write than all of this:
Code:
if (c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' ||
c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'X')
optimization == good
[edit] I am slow.