We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am trying to do a simple function to return values based on the input...shown below. char func (unsigned char add) { signed char i; switch (add) { case 0: i = 0; break; case 1: i = 1; break; case 2, 3, 4, 9: i = 9; break; case 10: i = 10;break; default: i = 99;break; } return i; } When i try to call func(2), it automatically jumps to the default.... Does the Keil C compiler support the multiple list case structure? MG
Hi,u may write it lik below: char func (unsigned char add) { signed char i; switch (add) { case 0: i = 0; break; case 1: i = 1; break; //case 2, 3, 4, 9: i = 9; case 2: case 3: case 4: case 9:i = 9;break; case 10: i = 10;break; default: i = 99;break; } return i; }