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




//char inventoryRequest = 'i';
//Function Definitions.
void displayInventory();
void inventory();
void exitGame();
int playGame();
int main()
{
//Menu Text.
cout<< "\t******Menu******\n\n";
cout<< "Please choose one of the following:\n";
cout<< "1 -Play Game.\n";
cout<< "2 -Exit.\n";


int choice;
cout<< "Choice: ";
cin>> choice;
string name;
switch (choice)
{
//Menu 1 choice.
case 1:
playGame();
break;
//Menu 1 choice.
case 2:
exitGame();
break;
default:
cout<< "That is not a choice!!!\n";
}


getchar();
getchar();
return 0;
}

//Method for play game.
int playGame()
{
//string inventory[10];
//inventory[0] = "stick";
//inventory[1] = "rock";
string name;
int age;
char sex;
cout<< "What is your name?\n";
cin>> name;
cout<< "What is your age?\n";
cin>> age;
cout<< "What is your sex, M or F?\n";
cin>> sex;
cout <<"Name:"<< name<<" Age:" << age<< " Sex:"<< sex;

cout << "\n\nIt is a cold and rainy night on board the Viking ship that is bringing " << name <<" to his terror.";
 inventory();
return 0;
}

void exitGame()
{
}

void inventory()
{

	char input[80];
	cin >> input;
	char inventoryRequest[] = "i";
	int invent = strcmp (input,inventoryRequest);
	//compare the player input to inventaryRequest (i) to see if they want to look at inventarty
	//invent = strcmp (input,inventaryRequest );
	 //char Input[80];
 /* do {
     printf ("Guess my favourite fruit? ");
     gets_s (input);
  } while (strcmp (input,inventoryRequest) != 0);
  */
	if(invent == 0)
	{

	cout <<  "hERE U ARE IN INVENTORY"<<endl;
	displayInventory();
	}

}

    void displayInventory()
	{
    const int SIZE = 10;
    string inventory[SIZE] = {0};
	inventory[0] = "Rock";
    inventory[1] = "Stick";
	inventory[2] = "Empty";
	inventory[3] = "Empty";
	inventory[4] = "Empty";
	inventory[5] = "Empty";
	inventory[6] = "Empty";
	inventory[7] = "Empty";
	inventory[8] = "Empty";
	inventory[9] = "Empty";
	inventory[10] = "Empty";
		cout << "blah" <<endl;
    for (int i = 0; i < SIZE; ++i) {
	
    std::cout << inventory[i];
    }
    getchar();
	getchar();
	}

Is the error from line 111 of you code? You are trying to write to inventory[10] which is illegal because you declared inventory as inventory[10] . This means that the valid range for the subscript is 0-9.

i can see that there is some thing wrong:

inventory[10] = "Empty";

while :

const int SIZE = 10;    
string inventory[SIZE] = {0};

so max is 9

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.