eof()的哪个头文件

问题描述:

我已经试过包含并包含“studio.h”。编译器说eof没有在这个范围内声明。eof()的哪个头文件

我有 如果(infile.peek()== EOF())

+1

不要你的意思infile.eof()? –

+0

有没有什么方法可以提前偷看2个角色而不会得到角色。 – Alex

+0

设置infile.peek()== infile.eof()不起作用。如何检查文件结尾的最后一个字符? – Alex

You'don't更好地参考以下主题:How does ifstream's eof() work?

在C语言中,你应该包括stdio.h并使用EOF常量。

#include "stdio.h" 
.... 
if (getc()==EOF){...} 

或使用C++这个参考:cstdio

#include <cstdio> 
#include <iostream> 
... 
if(infile.peek()==infile.eof())