home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / ANSIFLEN.C < prev    next >
C/C++ Source or Header  |  1992-04-26  |  632b  |  35 lines

  1. /*
  2. **  FLENGTH.C - a simple function using all ANSI-standard functions
  3. **              to determine the size of a file.
  4. **
  5. **  Public domain by Bob Jarvis.
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <io.h>
  10.  
  11. long flength(char *fname)
  12. {
  13.       FILE *fptr;
  14.       long length = 0L;
  15.  
  16.       fptr = fopen(fname, "rb");
  17.       if(fptr != NULL)
  18.       {
  19.             fseek(fptr, 0L, SEEK_END);
  20.             length = ftell(fptr);
  21.             fclose(fptr);
  22.       }
  23.  
  24.       return length;
  25. }
  26.  
  27. #ifdef TEST
  28.  
  29. void main(int argc, char *argv[])
  30. {
  31.       printf("Length of %s = %ld\n", argv[0], flength(argv[0]));
  32. }
  33.  
  34. #endif /* TEST */
  35.