Why does my program crash after running this particular function?
Posted
by
Tux
on Stack Overflow
See other posts from Stack Overflow
or by Tux
Published on 2012-10-13T21:24:57Z
Indexed on
2012/10/13
21:37 UTC
Read the original article
Hit count: 261
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?
Thanks in advance,
Johnny
void showInventory(player& obj) { // By Johnny :D
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";
i++;
}
}
std::string getItem(int i) {
return inventory[i];
}
© Stack Overflow or respective owner