I understand that cin.eof()
tests the stream format. And while giving input, end of character is not reached when there is wrong in the input. I tested
EOF stands for e nd o f f ile. std::cin is the standard input. The standard input, under normal circumstances, never reaches the end: you can always just type some more.
Further, .eof() only returns true if an input operation has already failed because of trying to read past the end of the file. The program actually can't tell that it's "at the end of file"; that is, the only way it can find out that the next attempt to read data will fail is by actually making the attempt.