[prog] C++
Wolfgang Petzold
petzold at villa-chaos.de
Tue Jan 20 16:30:01 EST 2004
Hi!
Since you declared Choice to be a char variable, I think you wanted to
be comparing it to chars in the switch statement instead of comparing it
to integers as you do. So I suggest
case '1': ...
case '2': ...
instead of
case 1: ...
case 2: ...
I think the compiler is able to do type casting from integer to char by
using the ASCII mapping. Unfortunately, the ASCII codes of '1' and '2'
aren't 1 and 2 respectively, but --who knows by heart?-- 0x21 and 0x22?
Anyway, that's why I think you don't get any compile time errors.
Cheers,
Wolfgang
More information about the Programming
mailing list