Hello, I am making a simple little text-based RPG/Dungeon Crawler game to help me practice C++. But I have come across an odd bug. I have narrowed it down to this bit of code:
...more code
cout << "A " << name << " attacks!" << endl;
//Checks who attacks first
int initiative = rand() % 2;
if(initiative == 0){
cout << "The " << name << " strikes first!" << endl;
int damage = (rand() % max + min);
hp =- damage;
cout << endl;
cout << "The " << name << " dealt " << damage << " points of damage!" << endl;
}
string bin;
cout << "Press any key to continue > " << flush;
cin >> bin;
system("cls");
//Combat loop
while(true){
...more code
If initiative = 1, than the program works like its supposed to: the enemy doesn't attack first and after the user inputs something after "Press any key to continue" the game continues on. But if initiative = 0 than it gets weird. It displays the "Enemy struck first...enemy dealt x damage" etc. but when the user enters input after it prompts "Press any key to continue" the program just enters an infinite loop with no text on screen. Any ideas as to why this could be happening?