On nested switches

hey guys. I'm new to this forum, but I'm a bit experienced in making the very basic programs.anyway,we have this project in our class, and I decided to do a short 'choose your destiny' game. But when I run it, the game halts to my tutorial prompt. I think it's the nested switch within the case of the main switch that's the problem. or is it? the program stops after the cin clause of the first switch statement.

here's a part. Oh yeah, we use the <stdio.h> library instead of the iostring.


printf("As soon as you enter the cave, you encounter a forked way.\n");
printf("Which way will you go?\n");
printf("[L]Left\n");
printf("[R]Right\n");
printf("[F]Forward\n");
printf("[B]Go back\n");
printf("enter choice:\n");
scanf("%c",&choice1); --this is where it stops.
while(cnt!=0){
switch(choice1){


case 'l':
case 'L':
{

puzzles pass1;
char temp[10];
pass1.pass[0]='e';
pass1.pass[1]='n';
pass1.pass[2]='t';
pass1.pass[3]='e';
pass1.pass[4]='r';
int x,cntr;
while (cntr!=0){
printf("The left way is dark and damp. the light turns a sickly green.\n");
printf("there's a door on one side.\n");
printf("a continuation of the tunnel lies on the other side.\n");
printf("There's something written on the wall.\n");
printf("what will you do?\n");
printf("[D]Go through the door\n");
printf("[T]Go through the tunnel\n");
printf("[R]Read the runes\n");
printf("enter choice:\n");
scanf("%c",&choice2);


switch(choice2){

case 'd':
case 'D':
{
yes, it's very long. remarks (and I need fast ones at the moment)?
Last edited on
Extra brace about 15 lines down. After case 'L'. No matching break statements. No closing brace for the first switch statement.

Post your whole code in between code tags. [code][/ code] (take the space out)
Last edited on
Well what do you mean by stop? Isn't it supposed to stop at the line you are indicating? Does it crash or is it stopped because it wants you to type some input? Obviously that statement is designed to stop the program temporarily because it is waiting for the user to type a character into the console window and press enter.

Also, please use code tags. Lastly it is better to just post the program within code tags so that we can compile it and run it very quickly. I can't even see where the choice1 variable is declared because you haven't posted a complete example.
Topic archived. No new replies allowed.