Bool While Loop

Hello,
I am really struggling currently with a while loop using a bool variable. This snippet is part of a larger picture but I need to understand what I am doing wrong with this while loop before I can proceed. I am asking the user if they have more data to input, and if so, it will loop back and ask the user to input more data but I am getting an infinite loop and I'm afraid I have done something wrong. Any help in the right direction would be much appreciated!

#include <iostream>
using namespace std;

bool done = true;

int main()

{
while (done == true)
{
cout << "Enter true to enter more readings or false to quit> ";
cin >> done;

}
system("pause");
return 0;

}
Last edited on
closed account (E0p9LyTq)
If someone types the letters false at the command prompt, they have entered 6 characters, not the boolean value of false. A user can't actually enter a false value for a boolean variable, someone can only enter what equates to a false value: the number 0 (zero).
Topic archived. No new replies allowed.