Getline causing strange bug

When I ask the player and they chose to play again, the first guess is read as a blank and it moves onto the second guess, this only happens when i play again, not during the first iteration of the game. I tried changing getline to a simple cin and it fixed it, so I’m confused as why getline is causing this.
Capture
Capture2

The first image is using getline, and the second is using a simple cin, where you can see the bug no longer occurs.

Nevermind, figured it out myself. Turns out that when I was asking for a response from the player as to whether or not they wanted to play again, I was using a simple cin, and that was causing the issue.

So I left the getline, and made the cin I was using for the play again response into a getline as well and that fixed it.

Privacy & Terms