Why am I exiting my do while loop?

I can't figure out why I am breaking out of my do while loop when both my conditions are true. Am I using the do while loop wrong? I've checked my variabes during debugging and they are still both set to true when it hits the while portion but then just skips over it rather then running it again.

PS i'm pretty new at coding, if you have a comment on my style please share it in a positive way ;)

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
do {
		cout << "Deep Forest Menu" << endl;	
		cout << "1. Go North" << endl;
		cout << "2. Go South" << endl;
		cout << "3. Go East"<< endl;
		cout << "4. Go West" << endl;
		cout << "5. Go North West" << endl;
		cout << "6. Go North East" << endl;
		cout << "7. Go South West" << endl;
		cout << "8. Go South East"<< endl;
		cout << "9. Cheat Sheet (temporary)" << endl;
		cout << "10. Show Location (temporary)" << endl;
		cout << "11. Show Stats" << endl;
		cout << "12. Click your heels" << endl;
		cout << "---------------------------------" << endl;
		cin >> input;
		switch (input){
		case 1:
			moveInForest("North");
			choice = true;
			break;
		case 2:
			moveInForest("South");
			choice = true;
			break;
		case 3:
			moveInForest("East");
			choice = true;
			break;
		case 4:
			moveInForest("West");
			choice = true;
			break;
		case 5:
			moveInForest("North West");
			choice = true;
			break;
		case 6:
			moveInForest("North East");
			choice = true;
			break;
		case 7:moveInForest("South West");
			choice = true;
			break;
		case 8:
			moveInForest("South East");
			choice = true;
			break;
		case 9:
			displayForest();
			choice = true;
			break;
		case 10:
			showPlayerLocationInForest();
			choice = true;
			break;
		case 11:
			player->showCurrentStats();
			choice = true;
			break;
		case 12:
			input = 12;
			choice = false;
			break;
		}
	}while((choice == true) && (playerIsNotDead == true));
You say both choice and playerIsNotDead are true, but the do while still exits?
Well, the computer can't be wrong, so let's see some relevant code (like, playerIsNotDead/choice declaration, initialization, etc.).
Last edited on
Topic archived. No new replies allowed.