C中printf中的`%p`有什么用?

在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