How do i handle big files (>10 GB) with c (at least reading them)? I don't have a 64bit machine, so the compiler Option
-D_FILE_OFFSET_BITS=64
won't work.
Asked
Active
Viewed 489 times
1 Answers
1
This looks likely to be a duplicate of Reading a large file using C (greater than 4GB) using read function, causing problems
Since you mention GCC, I'm assuming Linux, Solaris, or something similar. If you are using GCC on Windows, I don't know if the following will hold true.
If you just open
the file with O_LARGEFILE
and use read
, it should work, provided that you don't try to keep the entire file in memory and that your read
size is under 32 bits in size. Same for write
. If you need to seek, use lseek64
and compile with #define _LARGEFILE64_SOURCE
(note, lseek64
is not entirely standard, so if you aren't on Linux, the lseek
man page will hopefully point you to the prefered solution).

Community
- 1
- 1

Joshua D. Boyd
- 4,808
- 3
- 29
- 44