打印指针值 [英] Printing a pointers value
本文介绍了打印指针值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdio.h>
int main(void)
{
int x = 99;
int *pt1;
pt1 = &x;
printf("Value at p1: %d\n", *pt1);
printf("Address of p1 (with %%p): %p\n", pt1);
printf("Address of p1 (with %%d): %d\n", pt1);
return 0;
}
使用%d
而不是%p
的打印机指针值有哪些不利之处/危险?
What are the downsides/dangers to printer pointer values with %d
instead of %p
?
推荐答案
%d显示一个整数-指针的大小不必等于整数的大小.
%d displays an integer - there is no need for the size of a pointer to equal the size of an integer.
这篇关于打印指针值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文