|
|
while(!(cin >> age))
cin >> age;
|
|
|
|
std::cin >> age;
is formatted input, works best with numeric variables, what this means is that "cin" is expecting a number to be entered. Should you enter something other than a number like a letter or punctuation character "cin" will fail setting either the "fail" bit or "bad" bit or both. It also sets the good bit from (1) to (0) which is what the while condition is checking for.PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. Along with the proper indenting it makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |