Hello again. I was shown this small piece of code when making a command-line based menu, where you enter a number to perform a certain function.

while (true)
    {
        displayMenu();
        if(!(cin >> key)) {
            if(!cin.eof()) {
                cin.clear();
                cin >> dump;
            }
            continue;
        }
// etc

I cut the end off because it's not too relevant, but basically what follows is a switch function with the "key" passed to it. As I understand it, this piece of code takes integers and stores them in "key", and if it's not an integer is stores it in "dump", but I'm not sure why.

If someone could explain this to me, it would be much appreciated.

Keep on reading key and dump until user enters 0 .