gpt4 book ai didi

c++ - 为什么pread不能保证读取所有指定的字节?

转载 作者:太空宇宙 更新时间:2023-11-04 06:05:18 30 4
gpt4 key购买 nike

我用 C++ 编程,发现 pread 的工作非常有趣。

pread() 返回读取的字节数。返回的读取字节数可能与指定的要读取的字节数不同。

为什么pread不能保证读取所有指定的字节?

这个限制从何而来?

最佳答案

this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal. On error, -1 is returned, and errno is set appropriately. In this case it is left unspecified whether the file position (if any) changes.

来自 https://linux.die.net/man/2/read

关于c++ - 为什么pread不能保证读取所有指定的字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42173143/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com