DEV Community

Discussion on: C++ stuck inside while-loop?

Collapse
 
nanarayanan profile image
nanarayanan

Based on en.cppreference.com/w/cpp/io/basic...

Your program needs to clear the failure and skip the bad input.
cin.clear(); // unset failbit
cin.ignore(std::numeric_limitsstd::streamsize::max(), '\n'); // skip bad input

Your program needs to include limits (#include ) too.

I would suggest you pls go through further details given in the link above.