Anyone see the problem in my code?

What its supposed to do is when you look at the closet you find the key and escape but if you dont check the cupboard you will die
(yeah yeah i know its random but shit)
but instead when it gets to the part where you choose it instantly skips to the end(after switch)
so wat do?


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
#include <iostream>
#include <string>
#define audrey 0
#define cupboard 0
using namespace std;

int main()
{
	cout << "everything is so dark....." << endl;
	cin.get();
	cout << "\"HEY WAKE UP\"" << endl;
	cin.get();
    cout << "You open your eyes" << endl;
    cin.get();
	cout << "You find youself in a dark room" << endl;
    cin.get();
    cout << "You try to locate the voice but cant seem to find it.....";
    cin.get();
    cout << "\"EY TOSSER ON THE BLOODY CUPBOARD\"";
    cin.get();
    cout << "upon a quick look you realize that the voice is coming from a walkie talkie on" << endl << "the cupboard";
    cin.get();
    cout << "You pick up the walkie talkie" << endl;
    cin.get();
    cout << "smashing now what yer name?";
    cout << "(press enter and Choose name)";
    cin.get();
    string Charname; //Char name
    cin >> Charname;
    cout << "well splendid " << Charname<< " " << endl;
    cin.get();
    cout << "ok now here's the deal" << endl;
    cin.get();
    cout << "look " << Charname << " this room is your prison" << endl;
    cin.get();
    cout << "and no there will be no food" << endl;
    cin.get();
    cout << "You can however escape from here" << endl;
    cin.get();
    cout << "find the key, get out good luck";
    cin.get();
    cout << "You start looking around the room,and see 3 places worth" << endl << "searching" << endl;
    cout << "there is" << endl;
    int Pindus;
    teleport:
    cout << "1 - a bed" << endl;
    cout << "2 - a closet" << endl;
    cout << "3 - a cupboard" << endl;
    
    switch (Pindus)
    {
    case 1:
    cout << "the bed look kinda comfy but really dusty";
    goto teleport;
    
    break;
    
    case 2:
    cout << "you open the closet and find a cute little plant" << endl;
    cin.get();
    cout << "you examine the plant when it suddenly starts to talk!"<< endl;
    cin.get();
    cout << "Feed me " << Charname << "and i'll give you whatever you whant";
    cin.get();
    cout << "you toss a bucket of fish you had in your backpocket the plant" << endl << "spat it out furiously knocking you over and closing the door";
    cin.get();
    cout << "you landed on top of the rug and felt something hard under the rug!";
    cin.get();
    cout << "with a sigh of relief you find the key under the rug and put it in" << endl << "your pocket" << endl;
    cin.get();
    #define audrey 1
    break;
    
    case 3:
    cout << "This was a nice cupboard you might take it if you get out of here" << endl;
    cin.get();
    #define cupboard 1
    goto teleport;
    break;
    };
    if (audrey==cupboard);
    {
    	cout << "you take the cupboard and shove it in your backpocket" << endl;
    	cin.get();
    	cout << "you run for the door filled with joy!" << endl;
    	cin.get();
    	cout << "you turn the key in the lock and feel how the door slowly opens" << endl;
    	cin.get();
    	cout << "you've escaped congratulations!";
    	cin.get();
    	return 0;
    }
    if (audrey > cupboard);
    {
    cout << "You run for the door filled with joy!" << endl;
    cout << "You turn the key in the lock and feel how the door slowly opens" << endl;
    cout << "but suddenly the door slams shut and you hear a voice from the closet" << endl << "\"\"" << Charname << "\"\"" << endl;
    cout << "You did not escape..........";
    cout << "Game over";
    return 0;
    };
}
Last edited on
You don't actually fetch the user choice from the keyboard.
How do i do that?
im really new at programming
this is actually my third/fourth program
#define is a preprocessor directive. The preprocessor runs before compilation takes place so it does not care about the C++ syntax or any scoping rules.

#define audrey 0 This just means that all occurrences of audrey should be replaced with 0 (You would get the same program if you just replaced all audrey with 0 in the code manually).

Use int variables for audrey and cupboard instead.
Last edited on
How do i do that?

Much like you already do.
cin >> Charname;
i finally got it it was exactly as Moschops said and i forgot to use
cin >> Pindus
thank you
Last edited on
Topic archived. No new replies allowed.