The issue is that n
is an integer type but in the switch statemen, your comparing it against char
s.
You can use either of these two options to fix it,
- Change
n
to be a char type.
- Change the comparation to be an integer type.
For option 1, its a simple change.
char n;
For option two, change the '1'
, '2'
, '3'
, ... to 1
, 2
, 3
, ...
switch (n) {
case 1:
...
break;
case 2:
...
break;
...
}
Make sure you don't mix up integers and characters specially when comparing!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…