```
while(!(cin >> ar[i]))
    {
        cin.clear(); // clears bad input
        while(cin.get() != '\n')
            continue;
        cout << "Invalid input, please enter valid scores";
    }

```

The above code is from a much larger file. I copied this bit of a code from one of my textbooks and I don't really feel comfortable using it as I do not understand how this works. 

I am using it as a measure to handle input errors. 

So `ar` is an empty array of integers, if I decide to enter 'k', then

```
!(cin >> ar[i]) 

```

is true.

From here I clear the input buffer (I think that is correct, I'd like someone to confirm or dispute this please). The terminal then prints "Invalid input..." 
Now if I just press `Enter` nothing happens, but isn't `Enter` the newline char? So shouldn't the code read

```
while(cin.get() == '\n'

```

?