Hey there.
So, I never did fix a little annoyance I had with cin: the fact that if you have say
it just moves to the next line of the console with no complaints at all, and sits there waiting.
I'm currently using some code to deal with unexpected input which goes:
char inputBuffer[20];
std::cout << "Enter price: ";
valid = false;
while (!valid)
{
std::cin >> inputBuffer;
price = (float)atof(inputBuffer);
if (price > 0)
{
valid = true;
}
else
{
std::cout << "You must enter a positive non-zero number for price. Please try again." << std::endl;
std::cout << "Enter price: ";
}
}
but this doesn't solve the bug outlined above.
Does anyone have a workaround?