难道我们不应该为 whence
使用 SEEK_CUR
/SEEK_SET
或 SEEK_END
吗?它如何只使用固定值?
最佳答案
SEEK_SET
/SEEK_CUR
/SEEK_END
分别为0/1/2,可以使用数字或定义。
在这里查看定义:http://unix.superglobalmegacorp.com/BSD4.4/newsrc/sys/unistd.h.html
/* whence values for lseek(2) */
#define SEEK_SET 0 /* set file offset to offset */
#define SEEK_CUR 1 /* set file offset to current plus offset */
#define SEEK_END 2 /* set file offset to EOF plus offset */
当然,直接使用这些数字是不好的做法,因为它可能会在未来的实现中发生变化(虽然不太可能)
关于c - fseek(f,0,2);如果没有 SEEK_CUR/SEEK_SET 或 SEEK_END,这是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38226713/