Detecte o final da entrada do usuário CPP
while (cin.peek() != EOF) {
// To do your stuff...
// NOTE: peek() will set failbit when peeking end of stream and return EOF(-1).
}
Hilarious Hippopotamus