Mail Archives: djgpp/1993/05/05/13:00:53
On Wed, 5 May 1993, Wonkoo Kim, EE, U. of Pittsburgh wrote:
> filelength() determine the file size
This is probably the easiest to implement:
long filelength(FILE *fp) {
long orig, size;
orig = tell(fp);
fseek(fp, 0L, SEEK_SET);
size = fseek(fp, 0L, SEEK_END);
fseek(fp, orig, SEEK_SET);
return(size);
}
This will work on any ANSI C compiler and, of course, preserves the
original position of the file pointer. You could write a similar routine
for file handles if need be.
/* Andrew */
"As far as the laws of mathematics refer to reality, they are not certain;
and as far as they are certain, they do not refer to reality"
Albert Einstein
- Raw text -