How to print 'off_t' in C? [duplicate]
Possible Duplicate:
How should I print types like off_t and size_t?
I'm using fstat(stream, &fs)
to get a file size in C which returns type off_t
.
Printing this just gives a warning:
format ‘%d’ expects type ‘int’, but argument has 开发者_JAVA技巧type ‘off_t’
Any ideas how to print this without compiler errors?
Offset types are usually long integers. Cast it, and print it accordingly.
The actual type below off_t is defined in sys/types.h. You can look it up!
Found the answer, use:
%lld
Works without any casting.
精彩评论