DEV Community

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

bhupesh profile image
Bhupesh Varshney 👾 • Edited

Does this work ?

cout << "Enter your weight in kgs: " << flush;
if (!(cin >> weight)) {
    cout << "You did not enter a correct number!" << endl;
    // Leave the program, or do something appropriate:

Also make sure to add the #help tag to reach more visibility