home *** CD-ROM | disk | FTP | other *** search
- ===========================================================================
- BBS: The Abacus * HST/DS * Potterville, MI
- Date: 06-06-93 (12:16) Number: 84
- From: JOHN GREEP Refer#: NONE
- To: JEFFERY FOY Recvd: NO
- Subj: Finding a file's length Conf: (36) C Language
- ---------------------------------------------------------------------------
- JF>Short of reading a file byte by byte, what's the best way to
- JF>determine a file's length in bytes? (*exact* length that is)
-
- ___-Cut-Here-------------------8<----------------------------
-
- long file_length (FILE *fp)
- {
- long old_pos, length;
-
- old_pos = ftell(fp); /* Save file position */
-
- fseek (fp, 0L, SEEK_END);
- length = ftell(fp); /* Seek to end and get new position */
-
- fseek (fp, old_pos, SEEK_SET); /* Restore old file position */
-
- return length;
- }
-
- ___-Cut-Here-------------------8<----------------------------
-
- It is important to remember that file_length returns a long int and
- a pointer to an open file.
- _____________
- _/ () |-| /\/
-
- * OLX 2.1 TD * If this were an actual tagline, it would be funny.
-
- --- Maximus 2.01wb
- * Origin: SECRET C::The C Source*HST DS*(403)256-7019,Calgary,Ab (1:134/21)
- SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
- SEEN-BY: 153/752 154/40 77 157/110 159/100 125 430 575 950 203/23 209/209
- SEEN-BY: 261/1023 280/1 390/1 396/1 5 15 2270/1 2440/5 3603/20
-