C++ 试图在到达 EOF 时读取一个字符

C++ attempting to read a char when EOF is reached

ifstream inputFile("blah.txt");
char c;
inputFile.read((char *)(&c), 1);

假设在读取时,文件已经到达 EOF
c 中的值是多少?

Characters are extracted and stored until any of the following conditions occurs: ... end of file condition occurs on the input sequence ...

阅读更多信息:http://en.cppreference.com/w/cpp/io/basic_istream/read

因此您的 char 将包含与以前相同的值。