How to print 'off_t' in C?

Possible duplicate:
How do I print types like off_t and size_t?

I use fstat(stream, &fs)to get the file size in C, which returns a type off_t.

Printing this message simply gives a warning:

format ‘%d’ expects type ‘int’, but argument has type ‘off_t’

Any ideas on how to print this without compiler errors?

+3
source share
2 answers

Offset types are usually long integers. Copy it and print accordingly.

The actual type below off_t is defined in sys / types.h. You can watch it!

+6
source

Found an answer, use:

%lld

It works without casting.

+1
source

All Articles