我的老师说我们不应该使用EOF来读取文本文件或二进制文件信息,而是应该使用(afile>>x)这种方式。他没有解释原因,有人能解释一下吗?还能有人解释一下这两种不同读取方法的区别吗?
//Assuming declaration
//ifstream foobar
( ! foobar.eof() )
{
foobar>>x; // This is discouraged by my teacher
}
while (foobar>>x)
{
//This is encouraged by my teacher
}