
Easiest way to get file size (unix)?
Quote:
>I have a database file (filled with structures i've used fwrite() to create.
>what's the fastest way to determine the number of records in the database?
>If I could get the size of the file in bytes, I could do
> filesize / sizeof(record)
>but there doesn't seem to be a function in unix GCC to do this.
The compiler is not the issue - the question is does the OS rtl's have
a function that will do the job. The answer is yes - see later.
Quote:
>Turbo C on the PC has a "filelength" function that does exactly what i'm
>looking for, but unix has none.
Do a "man stat" for a function that returns detailed information on
files. This is, I believe, also available in Microsoft C and Borland
C, so is potentially much more portable than "filelength()".
Z
--
-------------------------------------------------------------------------
| Syed Zaeem Hosain P. O. Box 610097 (408) 441-7021 |
-------------------------------------------------------------------------