I have a switch statement with 6 cases. I wanted to declare some variables within case 5 that would only be used in case 5. The following did NOT work:
case 5:
int tempDegF = static_cast<int>(rtcDS3231.getTemperature()*1.8+32);
int startingY = map(tempDegF, -10, 110, 46, 21);
break;
case 6:
break;
but this did
case 5:
int tempDegF;
int startingY;
tempDegF = static_cast<int>(rtcDS3231.getTemperature()*1.8+32);
startingY = map(tempDegF, -10, 110, 46, 21);
break;
case 6:
break;
and this did as well
case 5:
int tempDegF = static_cast<int>(rtcDS3231.getTemperature()*1.8+32);
int startingY = map(tempDegF, -10, 110, 46, 21);
break;
// with case 5 as the final case in the switch statement
why is this?