Duplicate Case Values?

Hello all,

Recently, I started making a 'text-based adventure' game. I'm using the switch and case gates, but I'm getting an error.
Here's the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <iostream>

int main()
{
bool loop;
loop = 1;

bool looptwo;
looptwo = 1;

double box;
box = 0;
char action;
char actionA;
char actionC;
do{
	

	std::cout << "\n You awake in a dark cave. All you can see is a small fire in the distance.\n What would you like to do?\n"; 
	std::cout << "\n[A] Walk to the fire.\n";
	std::cout << "\n[B] Run to the fire.\n"; 
	std::cout << "\n[C] Stay where you are. You are comfy, after all.\n";
	std::cout << "\n[D] POOP YOURSELF. WHAT IS GOING ON?\n";
	std::cout << "\n\n\n (Tip) for any choice, press 'o' to start from scratch!\n";
	std::cin >> action;

switch (action)
{
	case 'a':
	
		loop = 0;
		std::cout << "\n You carefully approach the fire. Your vision remains dark and dull, but not for long. Slowly, you can see more clearly. By the fire you notice that there is a small box.\n";
	
	 
		if ( box == 2 )
		{std::cout << "\n During your examination of the box, you start to  hear a grumbling coming from the box. It starts shaking in your hands, to the point of your hands going numb.\n In your increasing panic, you...\n";}
		
			
		

		std::cout << "\n What would you like to do?\n";
		
		std::cout << "\n[A] Examine the box.\n";
		std::cout << "\n[B] Put the box in the fire.\n";
		std::cout << "\n[C] ROLL IN THE FIRE. IT LOOKS WARM.\n";
		std::cin >> actionA;
		
		switch (actionA)
		{	
			case 'a':	
			std::cout << "\n Picking up the box, you notice that it is extremely light, despite it's metal casing. There are the words 'BAD I-' written on it, and a blood stain covering the rest. You also notice a padlock blocking the opening mechanism.\n What would you like to do?\n";
			box + 1;
			break;
			
			case 'b':
			std::cout << "\n You pick up the box, and heft it into the flame. It sits there, not moving. Then, it melts, and in it you find some sort of machine. \n What would you like to do?\n";
			break;
	
			case 'c':
			{std::cout << "\n\n\n\n\n As your body melts in the flames, you find yourself drooling. The flames evaporate your spittle, and soon your skin melts.\n";
			std::cout << "\n Press [ENTER] to close the program...\n";
			std::cin.ignore();
	 		std::cin.get();
			looptwo = 1;
			loop = 0;
			break;

		}	
	break;
	case 'b':
	
	 loop = 0;
	 std::cout << "\n In your mad dash to the small glimpse of safety, you ironically trip over some sort of twig. You fall over some kind of bridge, invisible in\n the low light. The fall didn't kill you.\n\n\n\n\n But the lions did.\n";
	 std::cout << "\n Press [ENTER] to close the program...\n";
	 std::cin.ignore();
	 std::cin.get();
	 break;	
	
	case 'c':
	loop = 0;
	 std::cout << "\n You decide to stay put. Besides, who knows might be waiting for you at the \nfire? You decide to explore your surroundings, relying mostly on touch, as all you can see is the glowing embers in the distance. Using it as an anchor point, you feel around. You feel a hairy mass, a metallic stick, and a soft box shape.\n What would you like to do?\n";
	
		std::cout << "\n[A] Grab hairy mass and walk to fire.\n";
		std::cout << "\n[B] Grab stick and walk to fire.\n";
		std::cout << "\n[C] Grab box shape and walk to fire. \n";
		std::cin >> actionC;
			
		switch (actionC)
		{
			case 'a':
			std::cout << "\n You grab the hairy mass by a lock of its fur and slowly walk towards the fire. As the light grows, you find out to your horror that it was in fact a human head! \n\n Caught mid-scream, you...\n";
				break;
				
			case 'b':
				std::cout << "\n You snatch up the stick and take it to the fire. In the increasing light you notice that there is asolutely nothing spectial about it at all. \n\n You decide to...\n";
				break;

			case 'c':
				std::cout << "\n You take the box shape with you and continue towards the fire. the box turns out to be a pouch of some sort, held together with velcro. \n\n You choose to...\n";
				break;
		}
	break;
	case 'd':
	
	std::cout << "\n\n You accomplish absolutely nothing. Try again.\n";

	std::cout << "\n[A] Walk to the fire.\n";
	std::cout << "\n[B] Run to the fire.\n"; 
	std::cout << "\n[C] Stay where you are. You are comfy, after all.\n";
	std::cin >> action;
	
	case 'o':
	
	std::cout << "\n\n Starting over...\n ...\n ... \n done!\n\n";
	loop = 1;
	
	default:
	
		std::cout << "\n Nice try, Sherlock Holmes!\n";
	

} 
}while (loop == 1);
}



And now, I'm getting an error on line 70 saying:
In function 'int main()':
Line 70: error: duplicate case value
compilation terminated due to -Wfatal-errors.


Please note that I'm using codepad.org for my testing.
Thank you!
You shall not write such long lines as below because it is very difficult to read such code.

std::cout << "\n Picking up the box, you notice that it is extremely light, despite it's metal casing. There are the words 'BAD I-' written on it, and a blood stain covering the rest. You also notice a padlock blocking the opening mechanism.\n What would you like to do?\n";

If I am not mistaken this line has about 275 symbols. All lines shall not exceed 72 characters that they will be visible on the screen without scrolling it to the right.

You could write this line the following way

1
2
3
4
std::cout << "\n Picking up the box, you notice that it is extremely light, "
"despite it's metal casing. There are the words 'BAD I-' written on it, and a "
"blood stain covering the rest. You also notice a padlock blocking the opening "
"mechanism.\n What would you like to do?\n";


But it would be much better if you would use several lines with operator << spliting the original string into several strings by inserting the new line character.


The reason of the error is that you forgot to place one closing brace.


1
2
3
4
5
6
7
8
9
10
			case 'c':
			{std::cout << "\n\n\n\n\n As your body melts in the flames, you find yourself drooling. The flames evaporate your spittle, and soon your skin melts.\n";
			std::cout << "\n Press [ENTER] to close the program...\n";
			std::cin.ignore();
	 		std::cin.get();
			looptwo = 1;
			loop = 0;
			break;

		}


The last closing brace does not close the swithc statement. It closes inly the compound statement starting from

{std::cout << "\n\n\n\n\n As y....

Last edited on
Oh. Thank you so much! I've gotten it working now and I'm making great progress!
So, I've made a bit of progress, and here's what I've got:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include <iostream>
#include <time.h>
using namespace std;
int main()

{
bool loop;
loop = 1;

bool looptwo;
looptwo = 1;

double box;
box = 0;
double boxa;
boxa = 0;
double boxb;
boxb = 0;
char action;
char actionA;
char actionC;
bool poop;
poop = 0;
bool stickspear;
int stick;
stick = 0;
bool stickcheck;
stickcheck = 0;

	

cout << string( 100, '\n' );
	cout << "\n You awake in a dark cave. All you can see is a small fire in the distance.\n\n What would you like to do?\n"; 
do{
	cout << "\n[A] Walk to the fire.\n";
	cout << "\n[B] Run to the fire.\n"; 
	cout << "\n[C] Stay where you are. You are comfy, after all.\n";

	if (poop == 0)
	{cout << "\n[D] POOP YOURSELF. WHAT IS GOING ON?\n";}
	cout << "\n\n\n (Tip) for any choice, press 'o' to start from scratch!\n";
	cin >> action;

switch (action)
{
	case 'a':
		
		loop = 0;

cout << string( 100, '\n' );
		cout << "\n You carefully approach the fire. Your vision remains dark and dull, but not for long. Slowly, you can see more clearly. By the fire you notice that there is a\n small box.\n";
	do
		{
	 

			
		

		cout << "\n\n What would you like to do?\n";
		
		if (boxa != 1)

		{cout << "\n[A] Examine the box.\n";}

		if (boxb != 1)

		{cout << "\n[B] Put the box in the fire.\n";}

		cout << "\n[C] ROLL IN THE FIRE. IT LOOKS WARM.\n";
		cin >> actionA;
		
		switch (actionA)
		{	
			case 'a':
	
cout << string( 100, '\n' );
			cout << "\n Picking up the box, you notice that it is extremely light, despite it's metal \n casing. There are the words 'BAD I-' written on it, and a blood stain covering\n the rest. You also notice a padlock blocking the opening mechanism.\n";
			boxa ++;

			continue;
			
			
			case 'b':

cout << string( 100, '\n' );
			cout << "\n You pick up the box, and heft it into the flame. It sits there, not moving. \n Then, it melts, and in it you find some sort of machine. \n\n What would you like to do?\n";
			boxb ++;
			
			cout << "\n[A] Risk snuffing out your only light source for the machine.\n";
			cout << "\n[B] Leave the machine to melt. It's not important.\n";
			cout << "\n[C] See if you can grab it quickly from the fire.\n";
			
			if (stickspear == true)
			{cout << "\n[D] Use your stick to push it out of the fire.\n";
			



			break;

	
			case 'c':

cout << string( 100, '\n' );
			cout << "\n\n\n\n\n As your body chars in the flames, you find yourself drooling. The flames\n"
 " evaporate your spittle, and soon your skin melts.\n";
			cout << "\n Press [ENTER] to close the program...\n";
			cin.ignore();
	 		cin.get();
			looptwo = 1;
			loop = 0;
			boxb = 1;
			break;

			
			
		}
		}while (boxb == 0);	
	break;
	case 'b':
	
	 loop = 0;

cout << string( 100, '\n' ); 
	 cout << "\n In your mad dash to the small glimpse of safety, you ironically trip over some\n sort of twig. You fall over some kind of bridge, invisible in\n the low light. The fall didn't kill you.\n\n\n\n\n But the lions did.\n";
	 cout << "\n Press [ENTER] to close the program...\n";
	 cin.ignore();
	 cin.get();
	 break;	
	
	case 'c':
	loop = 0;

cout << string( 100, '\n' );
	 cout << "\n You decide to stay put. Besides, who knows might be waiting for you at the \n fire? You decide to explore your surroundings, relying mostly on touch, as all  you can see is the glowing embers in the distance. Using it as an anchor point, you feel around. You feel a hairy mass, a metallic stick, and a soft box shape.\n\n What would you like to do?\n";
	
		cout << "\n[A] Grab hairy mass and walk to fire.\n";
		cout << "\n[B] Grab stick and walk to fire.\n";
		cout << "\n[C] Grab box shape and walk to fire. \n";
		cin >> actionC;
			
		switch (actionC)
		{
			case 'a':

cout << string( 100, '\n' );
			cout << "\n You grab the hairy mass by a lock of its fur and slowly walk towards the fire\n As the light grows, you find out to your horror that it was in fact a human \n head! \n\n Caught mid-scream, you...\n";
			cout << "\n[A] Throw it away!\n";
			cout << "\n[B] Try to identify the head. You might know him...\n";
			cout << "\n[C] BURNITBURNITBURNITBURNIT!\n";	
			break;
				
			case 'b':

cout << string( 100, '\n' );
				cout << "\n You snatch up the stick and take it to the fire. In the increasing light you \n notice that there is asolutely nothing spectial about it at all. \n\n You decide to...\n";
				if (stickcheck == false)
				{cout << "\n[A] Further examine the stick.\n";}
				cout << "\n[B] Rip some of your shirt off and make the stick into a makeshift torch.\n";
				cout << "\n[C] Break the stick at the tip to make a spear.\n";
				cin >> stick;
				
				switch (stick)
				
				case 'a':
					cout << "\n Rolling the stick around in your hand, you notice a small tag on it. It reads 'GAS POWERED STICK! NOW 20% MORE GAS PER STICK!'\n";
					stickcheck = 1;		

				continue;


			case 'c':

cout << string( 100, '\n' );
				cout << "\n You take the box shape with you and continue towards the fire. the box turns \n out to be a pouch of some sort, held together with velcro. \n\n You choose to...\n";
				break;
		}
	break;
	case 'd':

cout << string( 100, '\n' );
	cout << "\n\n You accomplish absolutely nothing. Try again.\n";
	poop = 1;
	continue;
	
	case 'o':

cout << string( 100, '\n' );
	cout  << "\n\n Starting over...\n ...\n ... \n done!\n\n";
	poop = 0;
	continue;

	default:

cout << string( 100, '\n' );	
		cout << "\n Nice try, Sherlock Holmes!\n";
		continue;
	

} 
}while (loop == 1);
}
}


But now, It's telling me this:
In function 'int main()':
Line 201: error: expected `while' before '}' token
compilation terminated due to -Wfatal-errors.

Any ideas?
Any ideas?


Format your code properly.
You should check braces.
If you adopted a consistent bracing and indentation style, you would be able to see at a glance when you'd made a mistake. I strongly recommend you do so.
Line 94. Missing brace. And the very last brace on line 203 is superfluous.
Last edited on
So I indented, tweaked, and racked my brain over this one, but I still get issues. Here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#include <iostream>
#include <time.h>
using namespace std;
int main()

{
bool loop;
loop = 1;

bool looptwo;
looptwo = 1;

double box;
box = 0;
double boxa;
boxa = 0;
double boxb;
boxb = 0;
char action;
char actionA;
char actionC;
bool poop;
poop = 0;
bool stickspear;
int stick;
stick = 0;
bool stickcheck;
stickcheck = 0;

	

cout << string( 100, '\n' );
	cout << "\n You awake in a dark cave. All you can see is a small fire in the distance.\n";
do{
	"\n What would you like to do?\n"; 
	cout << "\n[A] Walk to the fire.\n";
	cout << "\n[B] Run to the fire.\n"; 
	cout << "\n[C] Stay where you are. You are comfy, after all.\n";

	if (poop == 0)
	{cout << "\n[D] POOP YOURSELF. WHAT IS GOING ON?\n";}
	cout << "\n\n\n (Tip) for any choice, press 'o' to start from scratch!\n";
	cin >> action;

switch (action)
{
	case 'a':
		
		loop = 0;

cout << string( 100, '\n' );
		cout << "\n You carefully approach the fire. Your vision remains dark and dull, but not for long. Slowly, you can see more clearly. By the fire you notice that there is a\n small box.\n";
	
		
	 

			
		

		cout << "\n\n What would you like to do?\n";
		
		if (boxa != 1)

		{cout << "\n[A] Examine the box.\n";}

		if (boxb != 1)

		{cout << "\n[B] Put the box in the fire.\n";}

		cout << "\n[C] ROLL IN THE FIRE. IT LOOKS WARM.\n";
		cin >> actionA;
		
		switch (actionA)
		{	
			case 'a':
	
cout << string( 100, '\n' );
			cout << "\n Picking up the box, you notice that it is extremely light, "
			"despite it's metal casing. There are the words 'BAD I-' written on it, and a "
			"blood stain covering the rest. You also notice a padlock blocking the opening "
			"mechanism.\n What would you like to do?\n";
			boxa ++;

			continue;
			
			
			case 'b':

cout << string( 100, '\n' );
			cout << "\n You pick up the box, and heft it into the flame. It sits there, not moving. \n Then, it melts, and in it you find some sort of machine. \n\n What would you like to do?\n";
			boxb ++;
		
			cout << "\n[A] Risk snuffing out your only light source for the machine.\n";
			cout << "\n[B] Leave the machine to melt. It's not important.\n";
			cout << "\n[C] See if you can grab it quickly from the fire.\n";
			
			if (stickspear == true)
			{cout << "\n[D] Use your stick to push it out of the fire.\n";}
			


	
			break;

	
			case 'c':

cout << string( 100, '\n' );
			cout << "\n\n\n\n\n As your body chars in the flames, you find yourself drooling. The flames\n"
			 " evaporate your spittle, and soon your skin melts.\n";
			cout << "\n Press [ENTER] to close the program...\n";
			cin.ignore();
	 		cin.get();
			looptwo = 1;
			loop = 0;
			boxb = 1;
			break;

			
			
		}
	
		case 'b':
		
		 loop = 0;

cout << string( 100, '\n' ); 
		 cout << "\n In your mad dash to the small glimpse of safety, you ironically trip over some\n sort of twig. You fall over some kind of bridge, invisible in\n the low light. The fall didn't kill you.\n\n\n\n\n But the lions did.\n";
		 cout << "\n Press [ENTER] to close the program...\n";
		 cin.ignore();
		 cin.get();
		 break;	
	
		case 'c':
		loop = 0;

cout << string( 100, '\n' );
		 cout << "\n You decide to stay put. Besides, who knows might be waiting for you at the \n fire? You decide to explore your surroundings, relying mostly on touch, as all  you can see is the glowing embers in the distance. Using it as an anchor point, you feel around. You feel a hairy mass, a metallic stick, and a soft box shape.\n\n What would you like to do?\n";
	
		cout << "\n[A] Grab hairy mass and walk to fire.\n";
		cout << "\n[B] Grab stick and walk to fire.\n";
		cout << "\n[C] Grab box shape and walk to fire. \n";
		cin >> actionC;
			
		switch (actionC)
		
			case 'a':

cout << string( 100, '\n' );
			cout << "\n You grab the hairy mass by a lock of its fur and slowly walk towards the fire\n As the light grows, you find out to your horror that it was in fact a human \n head! \n\n Caught mid-scream, you...\n";
			cout << "\n[A] Throw it away!\n";
			cout << "\n[B] Try to identify the head. You might know him...\n";
			cout << "\n[C] BURNITBURNITBURNITBURNIT!\n";	
			break;
				
			case 'b':

cout << string( 100, '\n' );
			cout << "\n You snatch up the stick and take it to the fire. In the increasing light you \n notice that there is asolutely nothing spectial about it at all. \n\n You decide to...\n";
			if (stickcheck == false)
			{cout << "\n[A] Further examine the stick.\n";}
			cout << "\n[B] Rip some of your shirt off and make the stick into a makeshift torch.\n";
			cout << "\n[C] Break the stick at the tip to make a spear.\n";
			cin >> stick;
				
			switch (stick)
				
				case 'a':
					cout << "\n Rolling the stick around in your hand, you notice a small tag on it. It reads 'GAS POWERED STICK! NOW 20% MORE GAS PER STICK!'\n";
					stickcheck = 1;		

					continue;


				case 'c':

cout << string( 100, '\n' );
					cout << "\n You take the box shape with you and continue towards the fire. the box turns \n out to be a pouch of some sort, held together with velcro. \n\n You choose to...\n";
					break;
	
			break;
case 'd':

cout << string( 100, '\n' );
	cout << "\n\n You accomplish absolutely nothing. Try again.\n";
	poop = 1;
	continue;
	
case 'o':

cout << string( 100, '\n' );
	cout  << "\n\n Starting over...\n ...\n ... \n done!\n\n";
	poop = 0;
	continue;

	default:

cout << string( 100, '\n' );	
		cout << "\n Nice try, Sherlock Holmes!\n";
		continue;
	

}
} while (loop == 1); 

}


And now I get this:


In function 'int main()':
Line 156: error: duplicate case value
compilation terminated due to -Wfatal-errors.

Last edited on
Nested switch statments are trouble because case labels are just that: labels. They don't regard scope, so the new switch blocks expose their labels to the outer switch block, therefore you get duplicated cases. In the snippets below, what ends up happening is that you expose case 'a': twice inside one switch block.
45
46
47
48
49
50
51
52
switch (action)
{
	case 'a':
		
		loop = 0;

cout << string( 100, '\n' );
		cout << "\n You carefully approach the fire. Your vision remains dark and dull, 

//...
73
74
75
76
77
78
		switch (actionA)
		{	
			case 'a':
	
cout << string( 100, '\n' );
			cout << "\n Picking up the box, you notice that it is extremely light,  
Last edited on
@booradley60

I see. What can I do instead? I would still like to have choices that lead to choices.
You could use nested 'if's instead of nested switches without changing the structure of your code that much. But I'm trying to think of something more clever.
Nested switch statments are trouble because case labels are just that: labels.

No they aren't.

For instance, the following works just fine:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

int main()
{
    char a = 'b', b = 'a' ;

    switch (a)
    {
    case 'a':
        switch(b)
        {
        case 'a': std::cout << b << '\n' ; break ;
        case 'b': std::cout << b << '\n' ; break ;
        }
        break ;
    case 'b':
        switch(b)
        {
        case 'a': std::cout << a << '\n' ; break ;
        case 'b': std::cout << a << '\n' ; break ;
        }
        break ;
    };
}


The problem is that ejuneau is using switch without the enclosing braces. Like if and for and while only the first line after the switch statement is controlled by the switch statement if braces are not used to indicate more than one line should be controlled.
Thank you Cire! I have taken your advice, and now at least it works, but not as it should. Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#include <iostream>
#include <time.h>
using namespace std;
int main()

{
bool loop;
loop = 1;

bool looptwo;
looptwo = 1;

double box;
box = 0;
double boxa;
boxa = 0;
double boxb;
boxb = 0;
char action;
char actionA;
char actionC;
bool poop;
poop = 0;
bool stickspear;
stickspear = 0;
int stick;
stick = 0;
bool stickcheck;
stickcheck = 0;

	

cout << string( 100, '\n' );
	cout << "\n You awake in a dark cave. All you can see is a small fire in the distance.\n";
do{
	"\n What would you like to do?\n"; 
	cout << "\n[A] Walk to the fire.\n";
	cout << "\n[B] Run to the fire.\n"; 
	cout << "\n[C] Stay where you are. You are comfy, after all.\n";

	if (poop == 0)
	{cout << "\n[D] POOP YOURSELF. WHAT IS GOING ON?\n";}
	cout << "\n\n\n (Tip) for any choice, press 'o' to start from scratch!\n";
	cin >> action;

switch (action)
{
	case 'a':
		
		loop = 0;

cout << string( 100, '\n' );
		cout << "\n You carefully approach the fire. Your vision remains dark and dull, but not for long. Slowly, you can see more clearly. By the fire you notice that there is a\n small box.\n";
	
		
	 

			
do{		

		cout << "\n\n What would you like to do?\n";
		
		if (boxa != 1)

		{cout << "\n[A] Examine the box.\n";}

		if (boxb != 1)

		{cout << "\n[B] Put the box in the fire.\n";}

		cout << "\n[C] ROLL IN THE FIRE. IT LOOKS WARM.\n";
		cin >> actionA;
		
		switch (actionA)
		{	
			case 'a':
			{
cout << string( 100, '\n' );
			cout << "\n Picking up the box, you notice that it is extremely light, "
			"despite it's metal casing. There are the words 'BAD I-' written on it, and a "
			"blood stain covering the rest. You also notice a padlock blocking the opening "
			"mechanism.\n What would you like to do?\n";
			boxa ++;

			continue;
			}
			
			case 'b':

cout << string( 100, '\n' );
			cout << "\n You pick up the box, and heft it into the flame. It sits there, not moving. \n Then, it melts, and in it you find some sort of machine. \n\n What would you like to do?\n";
			boxb ++;
		
			cout << "\n[A] Risk snuffing out your only light source for the machine.\n";
			cout << "\n[B] Leave the machine to melt. It's not important.\n";
			cout << "\n[C] See if you can grab it quickly from the fire.\n";
			
			if (stickspear == true)
			{cout << "\n[D] Use your stick to push it out of the fire.\n";}
			


	
			break;

	
			case 'c':

cout << string( 100, '\n' );
			cout << "\n\n\n\n\n As your body chars in the flames, you find yourself drooling. The flames\n"
			 " evaporate your spittle, and soon your skin melts.\n";
			cout << "\n Press [ENTER] to close the program...\n";
			cin.ignore();
	 		cin.get();
			break;

		
		}	
		}while (looptwo != 1);
			
		case 'b':
		{
		 loop = 0;

cout << string( 100, '\n' ); 
		 cout << "\n In your mad dash to the small glimpse of safety, you ironically trip over some\n sort of twig. You fall over some kind of bridge, invisible in\n the low light. The fall didn't kill you.\n\n\n\n\n But the lions did.\n";
		 cout << "\n Press [ENTER] to close the program...\n";
		 cin.ignore();
		 cin.get();
		 break;	
		}
		case 'c':
		{
		loop = 0;

cout << string( 100, '\n' );
		 cout << "\n You decide to stay put. Besides, who knows might be waiting for you at the \n fire? You decide to explore your surroundings, relying mostly on touch, as all  you can see is the glowing embers in the distance. Using it as an anchor point, you feel around. You feel a hairy mass, a metallic stick, and a soft box shape.\n\n What would you like to do?\n";
	
		cout << "\n[A] Grab hairy mass and walk to fire.\n";
		cout << "\n[B] Grab stick and walk to fire.\n";
		cout << "\n[C] Grab box shape and walk to fire. \n";
		cin >> actionC;
			
		switch (actionC)
		{
			case 'a':
			{
cout << string( 100, '\n' );
			cout << "\n You grab the hairy mass by a lock of its fur and slowly walk towards the fire\n As the light grows, you find out to your horror that it was in fact a human \n head! \n\n Caught mid-scream, you...\n";
			cout << "\n[A] Throw it away!\n";
			cout << "\n[B] Try to identify the head. You might know him...\n";
			cout << "\n[C] BURNITBURNITBURNITBURNIT!\n";	
			break;
			}	
			case 'b':
			{
cout << string( 100, '\n' );
			cout << "\n You snatch up the stick and take it to the fire. In the increasing light you \n notice that there is asolutely nothing spectial about it at all. \n\n You decide to...\n";
			if (stickcheck == false)
			{cout << "\n[A] Further examine the stick.\n";}
			cout << "\n[B] Rip some of your shirt off and make the stick into a makeshift torch.\n";
			cout << "\n[C] Break the stick at the tip to make a spear.\n";
			cin >> stick;
			}	
			switch (stick)
			{	
				case 'a':
				{
					cout << "\n Rolling the stick around in your hand, you notice a small tag on it. It reads 'GAS POWERED STICK! NOW 20% MORE GAS PER STICK!'\n";
					stickcheck = 1;		

					continue;
				}

				case 'c':
				{
cout << string( 100, '\n' );
					cout << "\n You take the box shape with you and continue towards the fire. the box turns \n out to be a pouch of some sort, held together with velcro. \n\n You choose to...\n";
					break;
				}
			}
			break;
		}
	}
case 'd':
{
cout << string( 100, '\n' );
	cout << "\n\n You accomplish absolutely nothing. Try again.\n";
	poop = 1;
	continue;
}	
case 'o':
{
cout << string( 100, '\n' );
	cout  << "\n\n Starting over...\n ...\n ... \n done!\n\n";
	poop = 0;
	continue;
}
	default:
{
cout << string( 100, '\n' );	
		cout << "\n Nice try, Sherlock Holmes!\n";
		continue;
}	

}
} while (loop == 1); 

}


I used the enclosing brackets by the switch statements, but it jumps to other outputs when I type stuff in.
Topic archived. No new replies allowed.