Hello
I am new to using switch cases and im trying to build a program that saves to a text file i looked up how to use switch cases on several sites and my code looks the same as what they have for switch cases so here is my code and can someone reply to tell me what i did wrong. My errors are illegal switch case on case 2 and 3. Thanks a lot. =)
You're using the switch case-statement incorrectly.
1 2 3 4 5 6 7 8 9 10 11 12
//Here is how you use it.
switch (expression)
case constant:
{
//your statements here...
break;
}
case constant:
{
//your statements here...
break;
}
1 2 3 4 5 6 7 8 9 10
//Here is how you should use it.
switch (expression)
{
case constant:
//your statements here...
break;
case constant:
//your statements here...
break;
}
And a on a related note, keep in mind that whereto is a variable of the data type int. In your switch case-statement, putting numbers between apostrophes makes them a char type value. Look up an ASCII chart on google to see what int values the characters 1 and 2 have (note: the characters 1 and to are not the same as the values 1 and 2).