Adventure game

1 #include<iostream>
2 #include<string>
3 #include<cstdlib>
4
5 struct survivor
6 {
7 string choice;
8 int society;
9 char string;
10 bool survived;
11 };
12
13 struct survivor bluelight (struct survivor alive)
14 {
15 cout << "You chose the blue light, You are welcomed to an amazing town of t tiny people in a close. \n They take care of you until you can walk again" << endl;
16 cout << "You can walk now what should you do?" << << endl;
17 cout << "1) Walk away" << << endl;
18 cout << "2) Thank them, and leave" << << endl;
19 cout << "3) Thank them, and ask for a way out" << << endl;
20 int gesture;
21 cin >> gesture;
22
23 switch(gesture)
24 {
25 case 1:
26 alive.string='n';
27 cout << "You just walked away and they attacked you, You died" << endl;
28 break;
29 case 2 :
30 alive.string='l';
31 cout << "They ignored your gratittude, but you left and got lost and ne ver found your way out" << endl;
32 break;
33 case 3 :
34 alive.string='r';
35 cout << "They heard your plead and gave you a map to the exit" << endl;
36 break;
37 };
38 return alive;
39 }
40 int main()
41 {
42 bool win_game=false;
43
44 struct adventurer alive;
45 alive.society = 0;
46 alive.string='x';
47 alive.survived=true;
48
49
50 cout "You wake up in a dark room and you see two lights \n Theres a blue light and a red light \n Which one would you follow? " << endl;
51 getline(cin, alive.choice);
52 cout << "You Chose" << alive.choice << endl;
53 while(alive.survived=true && win_game == false)
54 cout << "1) Follow thee blue light. " << endl;
55 cout << "2) Follow the Red light. " << endl;
56 int path;
57 cin >> path;
58 system("clear");
59 switch(path)
60 {
61 case 1:
62 alive=bluelight(alive);
63 break;
64 case 2:
65 //alive=redlight(alive);
66 //break;
67 }
68 if(alive.string='n')
69 {
70 cout << "You have made the little men angry you are dead" << endl;
71 alive.survived=false;
72 }
73 if (alive.string='l')
74 {
75 cout << " You didnt ask for help so now your lost and slenderman gets you" << endl;
76 win_game=true;
77 }
78 return 0;
79 }


I try to compile this and it wont let me it says that endl; was not declared. if someone would be kind enough to help me that would be great.
using namespace std;
might help.
Please use code tags to make it more readable.

As for your problem, it stems from the fact that endl is part of namespace std. So, in order to be able to type just "endl", you have to include the statement "using std::endl;". The same goes for a lot of other statements that come from an include statement.
Last edited on
Topic archived. No new replies allowed.