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)
        if(!(cin >> key)) {
            if(!cin.eof()) {
                cin >> dump;
// 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 .