什么是fread()中的”空项数”?

What is “short item count” in fread()?

当我是" man fread"时,我得到了:

RETURN VALUE
fread() and fwrite() return the number of items successfully read or written (i.e., not the number of characters). If an error
occurs, or the end-
of-file is reached, the return value is a short item count (or zero).

fread() does not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred.

所以我的问题是如何理解"空项数"。请忍受我的英语。为什么这里涉及"短"类型?有人可以举例说明"短缺项目数"是什么样的吗?谢谢。


fread手册页中" short"的含义不涉及数据类型。

在这种情况下,"短"表示"比预期少"。如果fread()预期读取4个对象,但仅读取3个对象,它将返回值3。

我认为该手册页应重写为:
"如果发生错误或到达文件末尾,则返回值是成功读取或写入的项目数,直到发生错误或EOF。


如果您想得到4,而您有3,那么您就短缺1。