Whenever I type the command to run this function in my program, it runs and then crashes saying:
“The application has requested the Runtime to terminate it in an unusal way.”
Why does it do this?
void showInventory(player& obj) {
std::cout << "\nINVENTORY:\n";
for(int i = 0; i < 20; i++) {
std::cout << obj.getItem(i);
i++;
std::cout << "\t\t\t" << obj.getItem(i) << "\n";
}
}
std::string getItem(int i) {
return inventory[i];
}
In this code:
Needs to be:
Credit to Prototype Stark!