Using a received string to choose an integer to save the value to

Hello everybody,

I don't even know how to call it, but I can't find my questions on the internet or in this forum. Hopefully somebody knows how to help me.

I'm trying to decide which integer to use by sending the value over an serial-connection. So what I have is a couple of state's:

int State01 = 0;
int State02 = 0;
int State03 = 0;
int State04 = 0;
int State05 = 0;
int State06 = 0;
int State07 = 0;
int State08 = 0;
int State09 = 0;

If I send information like "Switch01On" or "Switch02On", I would like to use the numbers 01 or 02 to decide which 'state' must be changed to '1'.

Is this even possible without a long list of if and else's?

Already thank you for the help!

Why not use an array?
Then the number you send is an index to the array.

AWOL:
Why not use an array?
Then the number you send is an index to the array.

Oh wow! I was breaking my head for hours. In only a few seconds you got me such a simple, but really helpfull solution. Thank you very much!