Usoing fopen etc is there a way to find file size

Discussion in 'C Programming' started by Angus Comber, Feb 9, 2004.

  1. Angus Comber

    Angus Comber Guest

    Hello

    I want to open the entire contents of a binary file (the files are quite
    small) into memory. How can I find out the file size in bytes of the file I
    am opening?

    Angus Comber
     
    Angus Comber, Feb 9, 2004
    #1
    1. Advertising

  2. Angus Comber wrote:

    > Hello
    >
    > I want to open the entire contents of a binary file (the files are quite
    > small) into memory. How can I find out the file size in bytes of the file
    > I am opening?


    See FAQs 12.40 and 19.12.

    --
    Richard Heathfield :
    "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
    C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    K&R answers, C books, etc: http://users.powernet.co.uk/eton
     
    Richard Heathfield, Feb 9, 2004
    #2
    1. Advertising

  3. Angus Comber

    Eric Sosman Guest

    Angus Comber wrote:
    >
    > Hello
    >
    > I want to open the entire contents of a binary file (the files are quite
    > small) into memory. How can I find out the file size in bytes of the file I
    > am opening?


    This is Question 19.12 in the comp.lang.c Frequently
    Asked Questions (FAQ) list

    http://www.eskimo.com/~scs/C-faq/top.html

    --
     
    Eric Sosman, Feb 9, 2004
    #3
  4. Angus Comber

    Default User Guest

    Angus Comber wrote:
    >
    > Hello
    >
    > I want to open the entire contents of a binary file (the files are quite
    > small) into memory. How can I find out the file size in bytes of the file I
    > am opening?



    http://www.eskimo.com/~scs/C-faq/q19.12.html



    Brian Rodenborn
     
    Default User, Feb 9, 2004
    #4
  5. Angus Comber

    Mike Wahler Guest

    "Richard Heathfield" <> wrote in message
    news:c0921p$kvi$...
    > Angus Comber wrote:
    >
    > > Hello
    > >
    > > I want to open the entire contents of a binary file (the files are quite
    > > small) into memory. How can I find out the file size in bytes of the

    file
    > > I am opening?

    >
    > See FAQs 12.40 and 19.12.


    I don't see a 12.40. Did you mean 12.38 (the highest number
    I see under section 12) ?

    Do I have the current link? http://www.eskimo.com/~scs/C-faq/top.html



    -Mike
     
    Mike Wahler, Feb 10, 2004
    #5
  6. Mike Wahler wrote:

    > "Richard Heathfield" <> wrote in message
    > news:c0921p$kvi$...
    >> Angus Comber wrote:
    >>
    >> > Hello
    >> >
    >> > I want to open the entire contents of a binary file (the files are
    >> > quite
    >> > small) into memory. How can I find out the file size in bytes of the

    > file
    >> > I am opening?

    >>
    >> See FAQs 12.40 and 19.12.

    >
    > I don't see a 12.40. Did you mean 12.38 (the highest number
    > I see under section 12) ?


    No, I meant 12.40 but it's my fault for not checking the online version. The
    book has a 12.40, but some of the book answers aren't present in the online
    version.

    --
    Richard Heathfield :
    "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
    C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    K&R answers, C books, etc: http://users.powernet.co.uk/eton
     
    Richard Heathfield, Feb 10, 2004
    #6
  7. Angus Comber

    Mike Wahler Guest

    "Richard Heathfield" <> wrote in message
    news:c09bd6$glp$...
    > Mike Wahler wrote:
    >
    > > "Richard Heathfield" <> wrote in message
    > > news:c0921p$kvi$...
    > >> Angus Comber wrote:
    > >>
    > >> > Hello
    > >> >
    > >> > I want to open the entire contents of a binary file (the files are
    > >> > quite
    > >> > small) into memory. How can I find out the file size in bytes of the

    > > file
    > >> > I am opening?
    > >>
    > >> See FAQs 12.40 and 19.12.

    > >
    > > I don't see a 12.40. Did you mean 12.38 (the highest number
    > > I see under section 12) ?

    >
    > No, I meant 12.40 but it's my fault for not checking the online version.

    The
    > book has a 12.40, but some of the book answers aren't present in the

    online
    > version.


    Ah, OK thanks, hadn't thought of that. I have the hardcopy of the
    C++ FAQs but not the C one. I suppose I'll put that on my list for
    next visit to the bookstore. :)

    -Mike
     
    Mike Wahler, Feb 10, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nonee
    Replies:
    2
    Views:
    2,657
    Neredbojias
    Oct 25, 2005
  2. uremae

    maximum file size of FOPEN

    uremae, May 19, 2005, in forum: C Programming
    Replies:
    15
    Views:
    8,739
  3. =?ISO-8859-1?Q?Martin_J=F8rgensen?=

    scanf (yes/no) - doesn't work + deprecation errors scanf, fopen etc.

    =?ISO-8859-1?Q?Martin_J=F8rgensen?=, Feb 16, 2006, in forum: C Programming
    Replies:
    185
    Views:
    3,401
    those who know me have no need of my name
    Apr 3, 2006
  4. Michel Rouzic
    Replies:
    4
    Views:
    1,837
    Michel Rouzic
    Apr 28, 2008
  5. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    413
    Fredrik Lundh
    Aug 13, 2008
Loading...

Share This Page