Unlike C, which starts counting at 0 (array elements :-), gcc starts counting function arguments at 1. So in printf (fmt, value)
, "argument 1" would refer to fmt
, and "argument 2" refers to value
. Easy, isn't it?
As for the correct integer type to printf an __off_t
, there currently is no 100% guaranteed and portable way. Your best bet is to cast it to the widest unsigned type your implementation supports. Note that an unsigned long
may only be 32 bits wide and you'd get problems with files >= 4GB. If you have a C99 implementation, or if it supports unsigned long long
, you should be fine with
printf("%llu", (unsigned long long)astatbuff->st_size);
There are discussions in the current POSIX standardization group to provide more printf() format specifiers matching other POSIX types like off_t
, pid_t
etc. Once that is out the door (don't hold your breath), printing file sizes will be a little more portable and elegant.