Need help understanding games in C++

This is a discussion on Need help understanding games in C++ within the C++ Programming forums, part of the General Programming Boards category; I have been trying to write a simple text adventure program using if statements and functions. When I run the ...

Need help understanding games in C++

I have been trying to write a simple text adventure program using if statements and functions. When I run the program it always reruns the program from the start. Also one of the commands should be exit to exit the game how is that done.

This is what I have but it is not working.
char exit(char)
{
cout << "press any key to continue....\n";
return 0;
}

Well I have no idea what it is you are trying to achieve with any of the code you have posted. You need to post all your code for it to make sense. But I have made some modifications to what is there that I think may help. Hopefully what is there is correct, been a while since I used some of these things. For strcmp to work #include <string.h>

Also, I changed exit to gameexit as there is already a function exit(0) which will quit your program.

void instructions()
{
cout << "Use u, d, r, and l to move the character.\n";
cout << "Type in exit to quit game or inventory to get a\n";
cout << "list of items you are carrying.\n\n\n\n";

}

//****************
// start of game *
//****************

void startGame()
{
char direction;
cout << "You are 10 years old and become lost while\n";
cout << "on a hiking trip with your family.\n";
cout << "The only direction you can move is right.\n";
cin >> direction;

//******************************
//able to retrieve a net *
//from a tree. This is *
//important as need to catch *
//fish later on. *
//******************************

void net()
{
char direction;
cout<< "You are further off the trail and deeper into the forest.\n";
cout<< "There is a net hanging from a tree.\n";
cout<< "You can move to the left or down.\n";
cin >> direction;