2GB limit on file size when using fwrite in C?

前端 未结 2 2038
一生所求
一生所求 2020-12-01 14:16

I have a short C program that writes into a file until there is no more space on disk:

#include 

int main(void) {
  char c[] = \"abcdefghij\"         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 14:56

    On a 32 bits system (i.e. the OS is 32 bits), by default, fopen and co are limited to 32 bits size/offset/etc... You need to enable the large file support, or use the *64 bits option:

    http://www.gnu.org/software/libc/manual/html_node/Opening-Streams.html#index-fopen64-931

    Then your fs needs to support this, but except fat and other primitive fs, all of them support creating files > 2 gb.

提交回复
热议问题