ftellofseeko
ftellofseeko is not a standard C function, but a colloquial term used to describe approaches that combine or choose between the traditional ftell/fseek and the larger-offset capable fseeko/ftello APIs to handle file positions portably. The distinction matters because ftell returns a long and fseek uses long offsets, which can overflow on large files. By using fseeko and ftello, which operate with off_t offsets, programs can handle larger files on platforms where off_t is 64-bit.
- ftell(FILE*) returns a long representing the current position, and fseek(FILE*, long offset, int whence) uses long
- fseeko(FILE*, off_t offset, int whence) and ftello(FILE* ) return and accept off_t offsets, enabling large-file support when
- POSIX and various C libraries provide fseeko/ftello as alternatives to the legacy functions; on some platforms
- For applications that must handle very large files, prefer fseeko/ftello to avoid overflow risks inherent in
- If targeting environments without fseeko/ftello, portable wrappers can fall back to ftell/ fseek, with caveats about
- When writing cross-platform code, use off_t for offsets and include appropriate headers; be aware of platform-specific
- To obtain the current position portably, use ftello if available; otherwise use a compatibility wrapper that
- To move relative to a position, use fseeko/ftello to describe offsets with off_t, ensuring consistency across
See also: ftell, fseek, fseeko, ftello, off_t, SEEK_SET, SEEK_CUR, SEEK_END.