Thread: size of a file

  1. #1
    Registered User
    Join Date
    Feb 2005

    size of a file

    Hi all,

    Other than using m = lseek(fildes, 0, 2) to find out the size of a file, do you know other ways of doing it?


  2. #2
    Chief Code Coloniser!
    Join Date
    Apr 2005
    Another option (instead of typing out the code, i ripped it off google )

        #include <sys/stat.h>
        struct stat results;
        if (stat("input.bin", &results) == 0)
            // The size of the file in bytes is in
            // results.st_size
            // An error occurred

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  5. archive format
    By Nor in forum A Brief History of
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM