when the play variable was a string variable. If you run the program (without stepping) and try to enter "y" to play again, the leftover whitespace was already read in, causing play to be an empty string (and hence ending the program before you actually get to enter "y" and have it be read in).
If you step through the simulation and enter "y" before cin is called to read in anything to play, then the whitespace is properly ignored and the program works as intended.
James says there's an inconsistency in where skipws() is used in overloading the >> operator for string variables. (At least, that's what I think he said. :) )
this was what James and Laura figured out using this example:
https://engr101staff.github.io/engr101.org/lobster-exercises/guess_function.html
when the
play
variable was a string variable. If you run the program (without stepping) and try to enter "y" to play again, the leftover whitespace was already read in, causingplay
to be an empty string (and hence ending the program before you actually get to enter "y" and have it be read in).If you step through the simulation and enter "y" before
cin
is called to read in anything toplay
, then the whitespace is properly ignored and the program works as intended.James says there's an inconsistency in where
skipws()
is used in overloading the>>
operator for string variables. (At least, that's what I think he said. :) )