【问题标题】:Which header file for eof()eof() 的哪个头文件
【发布时间】:2016-06-30 21:46:07
【问题描述】:

我尝试过包含和包含“studio.h”。编译器说 eof 没有在这个范围内声明。

我有 if(infile.peek()==eof())

【问题讨论】:

  • 你不是说infile.eof()吗?
  • 有什么方法可以在不获取字符的情况下查看前面的 2 个字符。
  • 设置 infile.peek()==infile.eof() 不起作用。如何检查文件末尾的最后一个字符?

标签: header eof


【解决方案1】:

你最好不要参考以下帖子: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())

【讨论】:

    猜你喜欢
    • 2013-10-07
    • 2014-04-13
    • 2014-12-24
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 2019-04-06
    相关资源
    最近更新 更多