|
From: Tor L. <tm...@ik...> - 2005-03-10 08:45:51
|
Earl Kinmonth writes:
> Nonetheless, when I wrote a programme that used stat() and _stati64(), the
> two nominally different routines seemed to return exactly the same (wrong)
> file size for my 4.8 gigabyte test file.
printf("%10lu ",sx.st_size);
The st_size field in struct _stati64 isn't an int, but a 64-bit
integer (long long in gcc parlance). The "l" printf format modifier
means "long", and a long is 32 bit just like an int. To print long
longs with the Microsoft C library (MSVCRT), use the "I64"
modifier. (Yes, this is not what the C libraries on Unix typically use
(they tend to double the "l" modifier), but then nobody says MSVCRT
tries to emulate Unix.) I.e.,
printf("%10I64u ",sx.st_size);
Also, remember, gcc -Wall is your friend.
--tml
|