Hi!
I made a simple function, which get's a file's size.
int file_size( char * filename )
{
int size;
struct stat st;
stat( filename, &st );
size = st.st_size;
return size;
}//file_size
It is working fine, but if i have a file which size is bigger than 4Gb than i get a negativ number back, and of course this isn't the correct file size. So how can i get such a big file's size? I think, that the return value should anything else like int but i don't know what, and i don't think, that would solve my problem.
Thanks,
kampi
Update:
Hi!
I found the solution. I have to use __stat64. I modifyed my function, and now it is retrieving the real size. I tested it with an 8Gb big file.
unsigned long long int file_size( char * filename )
{
unsigned long long int size;
struct __stat64 st;
__stat64( filename, &st );
size = st.st_size;
return size;
}//file_size
And a notice:
When i used printf, i had to use "%I64d" to print it out.