Max file size

This is a discussion on Max file size within the C Programming forums, part of the General Programming Boards category; Hello again, If ftell() return long type, is that mean that the maximum file size possible is LONG_MAX ??...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    84

    Max file size

    Hello again,

    If ftell() return long type, is that mean that the maximum file size possible is LONG_MAX ??

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Pretty much. Anything larger and you will have to resort to other APIs. I don't think the C standard has any other function for getting filesize, and especially not bigger than long.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Note here: just because ftell() can't return the correct size of the file does not mean this is the largest possible file-size. Native APIs may have different ways to give the value (e.g. a 64-bit integer even if "long" is 32-bit).

    Linux/Posix allows for a "fgetpos()" that has a larger value, for example.

    So, what I'm trying to say is "ftell() doesn't work on files longer than LONG_MAX", but it doesn't actually say ANYTHING about the largest possible file in that filesystem, OS or C runtime library.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    84
    Yep.

    I've created a 3000,000 kb.
    ftell() gave the right result until MAX_LONG after that it return -1.

    I actully created 9.5 GB file.
    Anyone know what is the limit in windows XP?

    Many thanks

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. Game of life
    By JoshR in forum C++ Programming
    Replies: 30
    Last Post: 04-03-2005, 02:17 PM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. File Size and File Size on Disk
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 12-15-2001, 07:03 PM

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