Hey Basically i have 2 functions:
void Inventory:: showInventory()
{
char input[80];
cin >> input;
char inventoryRequest[] = "i";
//compare the player input to inventoryRequest (i) to see if they want to
//look at inventory.
int invent = strcmp (input,inventoryRequest);
if(invent == 0) {
//vector<string> inventory;
cout << "You have " << inventory.size() << " items.\n";
cout << "\n******Inventory******";
cout << "\nYour items:\n";
for (int i= 0; i< inventory.size(); ++i) {
cout<< inventory[i] << endl;
}
}
}
void Inventory :: displayInventory(const string str) {
char input = 0;
do
{
cout << str << endl;
cin >> input;
}
while((input != 'i') && (input != 'I') && (input != 'n') && (input != 'N'));
showInventory();
//return input;
}
showInventory compares the player input to i. display inventory only lets the user press i or n. i to view the inventory and n to skip. But when i is pressed. It causes a double line.
Meaning i has to be pressed twice to view the inventory.
I have tried numerous things to stop this from occuring. But i have not succeeded and most of the time the inventory cannot be viewed at all.
Can anybody help me with this. Thanks in advance.