打印 pid_t 的正确 printf 说明符是什么 [英] What is the correct printf specifier for printing pid_t
本文介绍了打印 pid_t 的正确 printf 说明符是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前使用显式转换为 long 并使用 %ld
打印 pid_t
,是否有说明符,例如 %z
为 size_t
为 pid_t
?
I'm currently using a explicit cast to long and using %ld
for printing pid_t
, is there a specifier such as %z
for size_t
for pid_t
?
如果不是,打印 pid_t
的最佳方式是什么?
If not what the best way of printing pid_t
?
推荐答案
没有这样的说明符.我认为你在做什么(将 pid_t
转换为 long
并用 "%ld"
打印)很好;您可以使用更宽的 int 类型,但没有实现 pid_t
大于 long
并且可能永远不会.
There's no such specifier. I think what you're doing (casting the pid_t
to long
and printing it with "%ld"
) is fine; you could use an even wider int type, but there's no implementation where pid_t
is bigger than long
and probably never will be.
这篇关于打印 pid_t 的正确 printf 说明符是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文