should I use fseek SEEK_END [duplicate]

人盡茶涼 提交于 2019-12-01 08:21:42

The ftell function returns a long, which means that on an ILP32 system you can't correctly get the size of a file larger than 2GB. You should use the stat function or similar to get the size of a file; check the manual for the operating system you're targeting in case you have use a different function name (stat64) or define a preprocessor macro to get the desired behavior for large files.

Since C++ inherits fseek and SEEK_END from C, I'm quoting the C standard here:

C11(ISO/IEC 9899:201x) §7.21.9.2 The fseek function section 3

A binary stream need not meaningfully support fseek calls with a whence value of SEEK_END.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!