开发者

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

开发者 https://www.devze.com 2023-02-15 17:14 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How should I print types like off_t and size_t?
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

精彩评论

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