this is the code I use to display the size of the file "myfile_name"
struct stat stbuf;
if (stat("myfile_name",&stbuf)<0) {
fprintf(stderr, "\nError : %s \nErrno : %s","stat_big file",strerror(errno));
}
printf("ST_SIZE : %ld",stbuf.st_size);
st_size = -1509949440 (bytes) when the size of the file is 2,785,017,856 bytes (2.5)
I have searched for many hours for the solution, I have tried to add this line : #define _FILE_OFFSET_BITS 64
but it didn't work. Errno tells me that there is no error. Appearently, for the stat function, there is no overflow. In another question the answer was to use %ld
because of the type of stbuf.st_size
(off_t
) but it doesn't work.
The code works perfectly with small files.
You're help is very appreciated