Thread: size of FILE *fp?

  1. #1
    Unregistered
    Guest

    size of FILE *fp?

    Normally, when we want to know the size of an array we use
    sizeof(array) but how are going to know the size of the file pointed by fp i.e. FILE *fp? Please help!

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    28
    you can use size = ftell(fp);

    to do this you must first position the file position indicator at the end of the file, this is done using
    fseek(fp, 0L, SEEK_END).

    the value returned by ftell is the size of your file as a long int

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    6

    Smile Thanks a lot, pal!

    Dear SPOOK,

    Thank you very very much, indeed!! I have sought a lot of books just to find out the solution but to no avail. You are really my saviour!! Thanks again and thank for your anticipation.

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 Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM