having troubles with maze

so my teacher for computer programming recently assigned an assignment where we made a 3 room by 3 room maze and I'm having some trouble understanding whats going wrong with my code.

int main()
{
int choice;
printf("You have entered the maze in block 1, you can go to rooms 2 or 4.\n");
switch (choice)
{
case 1:
printf("You are already here.\n");
break;
case 2:
printf("You move to room 2. As you enter the room, the door closes behind you.\n");
break;
case 4:
printf("you move to room 4. As you enter the room, the door closes behind you.\n");
break;
default:
printf("You walk into the wall trying to reach the room, Try again.\n");
break;
}
_getch();
return 0;
}

This is just the first part. There are 9 rooms total that we create and each time we enter a room, the door closes behind us.

Any ideas as to whats going wrong? Visual studio is saying that choice is being used as an uninitialized local variable and is preventing the code from running.
You need to input choice using scanf. Also, the way you currently have your choices set up is unscaleable, there are better ways of doing it (such as using as an array).
Topic archived. No new replies allowed.