Whats gone wrong?

when running this programm i get the error:


c:\documents and settings\daniel\my documents\visual studio 2008\projects\learn c++\learn c++\main.cpp(21) : error C3861: 'tutorial': identifier not found



#include <iostream>
#include <string>
using namespace std;

int source;
int tutorialstage = 1;
int life = 1;
string command;
size_t found;

int main()
{
cout << "You wake up to the buzz of the alarm clock. You reach over and hit the snooze button and try to go back to sleep. But it's impossible, once your up, you can't go back to sleep. You roll out of bed, adjusting your eyes to the light peeping through the curtains." << endl << endl << "7:00 am...too early." << endl << endl << "You glance over at the clock, and recoil in horro when you see that in fact the time is 8:00. The alarm must have been set wrong. Hurriedly you get dressed and run out the door." << endl << endl << "As you reach the school gates you hear a group of chavs call 'Run, Forest, Run.'" << endl << endl << endl << "[The next stage is the tutorial. If you get stuck at any time, type '/help'. If you wish to exit the game type '/exit'. If you see this sign: (>), type 'continue' to carry on." << endl << endl;
do {
getline (cin,command);

cout << ">>> ";

if (tutorialstage != 0)
{
tutorial (); //THIS IS LINE 21!!!!!!
}

found=command.find("go");
if (found == 0)
{
cout << "Go where?";
}

found=command.find("exit");
if (found == 0)
{
life = 0;
}

} while (life == 1);
}

void tutorial ()
{
cout << "Meh";
}
please ignore everything not relevent to the problem, i havnt finished the rest of the code yet....
I did the same thing in fact :P

EDIT: oops....if your still having the same problem after you finish, heres your solution(lol):

somthing like this should work:

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

void tutorial ()
{
cout << "Meh";
}

int source;
int tutorialstage = 1;
int life = 1;
string command;
size_t found;

int main()
{
cout << "You wake up to the buzz of the alarm clock. You reach over and hit the snooze button and try to go back to sleep. But it's impossible, once your up, you can't go back to sleep. You roll out of bed, adjusting your eyes to the light peeping through the curtains." << endl << endl << "7:00 am...too early." << endl << endl << "You glance over at the clock, and recoil in horro when you see that in fact the time is 8:00. The alarm must have been set wrong. Hurriedly you get dressed and run out the door." << endl << endl << "As you reach the school gates you hear a group of chavs call 'Run, Forest, Run.'" << endl << endl << endl << "[The next stage is the tutorial. If you get stuck at any time, type '/help'. If you wish to exit the game type '/exit'. If you see this sign: (>), type 'continue' to carry on." << endl << endl;
do {
getline (cin,command);

cout << ">>> ";

if (tutorialstage != 0)
{
tutorial (); //THIS IS LINE 21!!!!!!
}

found=command.find("go");
if (found == 0)
{
cout << "Go where?";
}

found=command.find("exit");
if (found == 0)
{
life = 0;
}

} while (life == 1);
}


C++ reads code line for line, so when you put that void at the end it wont read it till the end, therefore it thought u hadnt declared tutorial();
i did the same thing with a struct. :P hope that helpys you out.
Last edited on
that works well but what would i have to do if i wanted void tutorial to be in a different source file. (I am using MS Visual C++)
Do u mean call the void tutorial function from another source file? i wouldnt know how to do that. File I/O cmds would probably work for that sort of thing though.

http://www.cprogramming.com/tutorial/lesson10.html
^File I/O stuff you can read


Best of Luck
Orville.
@Loves FileI/O???? wtf...?
@awaste what you want to prototype the function above where it is used:

 
void tutorial();


Then you can define it wherever you want.
@firedraco i misunderstood his question thats so rude dude.
Last edited on
Topic archived. No new replies allowed.