Dev C++ program closes immediately when entering letters

if x is a float type or an integer type

std::cin >> x;

reads no letter from std::cin if std::cin starts with a character that cannot be a prefix for a float or an integer type.

So x remains to 0 and your input stream remains unchanged.

For the next

std::cin >> y;

with y of type float or integer, the same behavior occurs: y remains to 0 and your input stream std::cin still starts with a character that cannot be read by a float or an integer type.

This behavior goes on until the end of your program.

Leave a Comment