Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

File size information in C

Name: Anonymous 2010-05-29 15:30

Hey, /prog/

When you have a pointer to a FILE structure, what's the standard way of determining the size (in bytes) of the open file?

Name: Anonymous 2010-05-29 16:03

Use fseek to position the file pointer at the end of the file, then get the position using ftell and finally use fseek or rewind to position the file pointer back at the start.

ftell returns the offset as a long int, so it may fail on files whose sizes cannot be represented as a long int.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List