Linux中off_t的打印格式说明符 [英] print format specifier of off_t in linux
问题描述
如何打印类型为off_t的变量的值.
Hi,
How do i print the value of a variable of type off_t.
推荐答案
好吧,off_t
定义为:
Well,off_t
is defined as:
off_t文件偏移量,以从文件或设备开头开始的字节数为单位. off_t通常定义为带符号的32位整数.在启用大文件的编程环境中,off_t被定义为带符号的64位整数.
off_t File offset, measured in bytes from the beginning of a file or device. off_t is normally defined as a signed, 32-bit integer. In the programming environment which enables large files, off_t is defined to be a signed, 64-bit integer.
这意味着您可以将大小(以字节为单位)与32位整数和64位整数进行比较(以确定大小),并在转换后以带符号的32/64位整数(使用其格式说明符)进行打印.
Which means you can compare the size (in bytes) to a 32bit integer and a 64bit integer (to determine the size) and print as either a signed 32/64 bit integer (using their format specifier) after casting.
off_t someVar;
printf(%ld \ n",(long long)someVar);
off_t someVar;
printf("%ld\n", (long long)someVar);
这篇关于Linux中off_t的打印格式说明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!