Quote:
>> I may have been looking at the source and K&R too long, but for some
>> reason, I can't find an easy way to retrieve the size of a file. I use
>> QuickC (IBM PC). Anything ANSI standard would be appreciated, but if it's
>> "tweakable", that would be great, too.
>[Uses this under unix}
>FILE *f;
>long length;
>f = fopen(....);
>fseek(f, 0L, 2); /* position at 0 bytes (0L) from end of file (2) */
>length = ftell(f); /* return where we are now */
Be aware this is not guaranteed to work. The return value of ftell and
the second argument to fseek are not required to byte-counts from any
particular point; it's allowed for these values to be magic cookies. The
only requirement is that fseek() will take the result of an ftell() and
return to that spot.
--
University of Kentucky +1 606 257 2975
Department of Mathematics
Flame early, flame often.