c program, file size limit, how to solve? 2G bytes limit.

Discussion in 'C++' started by guru.slt@gmail.com, Jun 27, 2005.

  1. Guest

    my c program fails to write file that is bigger than 2G bytes. I used
    gcc compiler. After writing for a while, It says: "filesize limit
    exceed". How to solve this?

    But, if I compile the c code by "c++", then it can write more than 2G
    bytes in a file. Where is the problem for "gcc"?

    the code is here:
    ---------------------------
    #include <stdio.h>
    #include <string.h>

    int main()
    {
    char buffer[2281];

    FILE* f_p;
    f_p = fopen("output.vi", "w");

    int i;
    for (i = 0; i < 2280; ++i) buffer = 'a';
    buffer = '\n';

    while(1)
    fwrite(buffer, 1, 2281, f_p);

    }
    ------------------------------
    , Jun 27, 2005
    #1
    1. Advertising

  2. wrote:
    > my c program fails to write file that is bigger than 2G bytes. I used
    > gcc compiler. After writing for a while, It says: "filesize limit
    > exceed". How to solve this?
    >
    > But, if I compile the c code by "c++", then it can write more than 2G
    > bytes in a file. Where is the problem for "gcc"?


    Uh... Your problem seems to be either of the "C" sort (in that case ask
    in comp.lang.c, down the hall) or of the "GCC" sort (in that case ask in
    gnu.gcc.help, around the corner). In either case, I don't see a C++ one.

    V
    Victor Bazarov, Jun 28, 2005
    #2
    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. Jason Collins
    Replies:
    3
    Views:
    5,995
    Jason Collins
    Feb 18, 2004
  2. Replies:
    5
    Views:
    519
    Flash Gordon
    Apr 9, 2006
  3. Yandos
    Replies:
    12
    Views:
    5,098
    Pete Becker
    Sep 15, 2005
  4. Replies:
    8
    Views:
    483
    Bob Hairgrove
    Apr 10, 2006
  5. scad
    Replies:
    4
    Views:
    941
    James Kanze
    May 28, 2009
Loading...

Share This Page