Thread:Icefirephoenix/@comment-34929636-20181207021129/@comment-34929636-20181212132309

while (!(cin >> randomName)) cout << "Invalid input.";

An example of a trick you have to memorize. works with any input stream, and if actually preferable to using fin.eof, as it prevents the last value being returned twice.