c++ - ferror() 返回值的消息文本

标签 c++ c error-handling io

如何获取 int ferror(FILE*) 返回的错误代码消息?对于 errno,有 char * strerror(int)。 ferror 返回的代码是什么?如果 char * strerror(int) 对此也有好处,那么我需要它的引用(我没有找到这种情况的任何指标)。

最佳答案

来自 this reference page :

The ferror() function shall test the error indicator for the stream pointed to by stream.

这意味着 ferror 返回一个 bool 值,告诉您是否有错误,仅此而已。但根据 POSIX 规范,errno 的值将包含一个错误代码,以防出现故障。

关于c++ - ferror() 返回值的消息文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15473699/

相关文章:

c - 为什么此代码在动态分配期间会崩溃?

oracle - 如何显示Oracle嵌套游标循环的错误消息

c++ - 如何以编程方式阻止Linux操作系统用户空间中的USB存储设备

c++ - 适用于事件管理的设计模式

C将指针传递给函数,如何?

php - 使用 mysql 从 php 插入时出现问题

error-handling - 通过 ABAP 删除 BOPF 消息(来自/bobf/if_frw_message)

c++ - STL:如何为 <vector> 重载 operator=?

C++重载运算符=以获得右手和左手重载

c - 检索任务栏停靠位置: result incorrect