Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

Gray-Ice

个人博客兼个人网站


title: C语言打印指针地址
categories:
- blog
- C

发现GCC加了-Werror后C primer plus上打印指针地址的代码无法通过编译,于是问了群里大佬,得到了答复,下面我把能够通过编译的代码贴上:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#define SIZE 4

int main(void)
{
int p[SIZE];
int * pt;
pt = p;
printf("%p\n", (void *)pt);
return 0;
}

下面是执行结果:

1
2
3
4
5
6
7
8
9
10
~/codeSet/CCode ⌚ 10:48:51
$ gcc -Wall -Werror -Wextra -pedantic -Wconversion test.c

~/codeSet/CCode ⌚ 10:49:16
$ ./a.out
0x7ffc359a0c90

~/codeSet/CCode ⌚ 10:49:17
$

评论



愿火焰指引你