我试图打印指针变量的地址而不是它指向的地址,有人能帮我实现吗?以下是我正在尝试的,但它显示了我无法解决的警告。谢谢!
#include <stdio.h>
#include <stdlib.h>
int main()
{
int* y;
printf("%p\n",y);
printf("%x\n",&y);
y = (int*)malloc(sizeof(int));
printf("%p\n",y);
printf("%x\n",&y);
return 0;
}
编译警告:
Warning: format ‘%x’ expects argument of type ‘unsigned int’,
but argument 2 has type ‘int **’
Output:
0xb773fff4
bfa3594c
0x8361008
bfa3594c