Input into a switch statement to change position of a character.

I'm trying to make a simulation of Travelling sales man problem. So I got random circles spawning and each circle.

I want to make it so I can switch between the circles. Currently the player spawns to the first circle created which is in position (cir[0].x, cir[0].y). However, I'm trying to make an input so you can type in for example 12 and the position of the queen would now be (cir[12].x, cir[12].y). But, this seems to not work.

int number;
cin>>number;

if(number<NUMCIRC)
{
switch(number)
{
case number:
queenX = cir[number].x;
queenY= cir[number].y;
break;

default: break;

}
}


I was wondering as surely if I input the number and then press enter it should jump to the number. Assuming it's smaller than NUMCIRC, which is the number of circles that I have spawned.

Your switch statement is completely superfluous because you're not switching between anything. The point of an array is you can select a value by its numerical index. I'm not entirely sure how the switch statement will execute with a variable case. Regardless, you can achieve the desired result with the following code.
int number;

• case labels must be Integral Constant Expressions. That's "more constant" than a regular const; the compiler has to know the values. But this is indeed the correct solution; switch is in no way related to the problem. Jul 31 '12 at 13:27