Because the switch
statement can take only constants, you know when reading the code that the things you're comparing against are all constants. On the other hand, you would use if
statements (or some other structure) to compare against variables:
if (c == up_key) {
move(0, -1);
} else if (c == down_key) {
move(0, 1);
} else ...
This provides a distinct difference in structure which can greatly aid those who come after you in reading your code. Imagine if you had to look up every case
label to see whether it was a variable or not?