checking file size?

This is a discussion on checking file size? within the C++ Programming forums, part of the General Programming Boards category; any function will help to check a file size??...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    checking file size?

    any function will help to check a file size??

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,699
    Code:
    f.seekg(0,ios::end);
    long size = (long)f.tellg();
    Or use seekp()/tellp().

    gg

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    ... and read this too
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    thank you

    thank you so much....i will try that out

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,699
    ...ftell is not guaranteed to return a byte count except for binary files...
    "ftell" is the equivalent of tell[p,g](). Be sure to open the file in binary mode for determining the size.

    (good call Hammer)

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 02:30 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 04:44 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21