Minor problems for a minor program

Hi, I picked up a book about simple game programming, so I was teaching my brother what little I know. When we tried to compile, we got this...


Mythiquest.cpp: In function ‘int main()’:
Mythiquest.cpp:25:1: error: expected initializer before ‘cout’
Mythiquest.cpp:32:8: error: ‘beasthunter’ was not declared in this scope


So... easy fix? I have looked and don't understand it. Here is his 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
//Doesnt Appear
//Made By Harry Rowan





#include<iostream>                       //Include File. Iostream is a file
#include<string>

using namespace std;                     //Namespace is like an area code for a phone number. Its a directory
                                           
int main()                               //This defines the main function of the program

{                                        //This opens the main program. Anything withing this is the main progaram

const int ARROWS = 7;                    //This is a CONST int which is a constant number. This cannot be changed

int gryffin = 2, unicorn = 1, goblin = 5, soul = 4;      //Int is a (whole) number. It aplies a number to the type name
 
string beasthunter                                      //String is a group of chars or simply a word



cout << "Welcome to my first C++ Game called Mythiquest\n" << endl;  // These word are going to be outputted

cout << "The objective of the game is to kill all the creatures and save the world of threat!\n" << endl; //cout is an output

cout << "Gryffin are hard to beat, while goblins and souls are easier. When you meet a unicorn, it will heal you totally\n" << endl;

cout << "Please enter your name: " << endl;                 //
cin >> beasthunter >> endl;                                   //Using cin to funnel out a word to beast_hunter

return 0;

}
Hi,

On line 21, there is a semicolon missing (after beasthunter).
You are missing a semicolon after string beasthunter

You can not put an endl at the end of a cin statement like this.
 
cin >> beasthunter >> endl;   


I would put a separate cout statement with the endl after it.
Thanks for all of the quick feed back! I love this forum and its inhabitants :3
Topic archived. No new replies allowed.