C 中 `%p` 在 printf 中的用途是什么?


在 C 中,我们已经了解了不同的格式说明符。在这里,我们将看到另一个格式说明符 %p。它用于打印指针类型的数据。让我们来看一个示例来更好地理解。

示例

#include<stdio.h>
main() {
   int x = 50;
   int *ptr = &x;
   printf("The address is: %p, the value is %d", ptr, *ptr);
}

输出

The address is: 000000000022FE44, the value is 50

更新于: 2019-7-30

11K+ 浏览量

开启您的 职业生涯

通过完成课程获得认证

开始吧
广告
© . All rights reserved.