I am trying to write a function that relates a color; for example, brown with a number, say 1. so when the user types brown 1 will appear, etc.
int colortonumber (int x)
{
int nka;
switch (x)
{
case 'brown':
nka=1;
break;
case 'red':
nka=2;
break;
case 'orange':
nka=3;
break;
case 'yellow':
nka=4;
break;
case 'green':
nka=5;
break;
case 'blue':
nka=6;
break;
case 'violet':
nka=7;
break;
case 'gray':
nka=8;
break;
case 'white':
nka=9;
break;
default:
nka=-1;
}
return nka;
}
is there any way possible to have strings in switch statements?