开发者

How to print 'off_t' in C? [duplicate]

This question already has answers here: Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜