intptr_t 和 uintptr_t 的字符串格式 [英] string format for intptr_t and uintptr_t

查看:25
本文介绍了intptr_t 和 uintptr_t 的字符串格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

intptr_t uintptr_t 的字符串格式是什么,对 32 位和 64 位架构都有效.

What is the string format for intptr_t and uintptr_t which is valid for both the 32 and 64 bit architecture .

编辑

warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type "AAA"

这是我在 64 位而不是 32 位中收到的警告.

This is the warning i am getting in 64 bit but not in 32 bit.

  intptr_t  AAA

推荐答案

这将是 inttypes.h 中的以下宏:

That would be the following macros from inttypes.h:

对于 printf:PRIdPTR PRIiPTR PRIoPTR PRIuPTR PRIxPTR PRIXPTR

对于 scanf:SCNdPTR SCNiPTR SCNoPTR SCNuPTR SCNxPTR

使用示例:

uintptr_t p = SOME_VALUE;
printf("Here's a pointer for you: %" PRIxPTR "
", p);

这篇关于intptr_t 和 uintptr_t 的字符串格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆