Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>filelength() return file length</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 filelength()            Return File Length

 #include   <io.h>                       Required for declarations only

 long       filelength(handle);
 int        handle;                      Handle referring to open file

    filelength() returns the length of the file associated with 'handle'.

    Returns:    The file length in bytes, if successful; on error, -1L is
                returned and 'errno' is set to EBADF (invalid file
                handle).

 Portability:   Applies to MS DOS only.

   -------------------------------- Example ---------------------------------

    The following statements open a file and find its length.

           #include <io.h>
           #include <stdio.h>
           #include <stdlib.h>

           FILE *in;
           long length;

           main()
           {
               in = fopen("invoice.dat","r");
                 .
                 .
                 .
               length = filelength(fileno(in));
           }


See Also: fileno() chsize() fstat() stat()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson