main fap addr 0xbfc8d308 fap contian 0x23911a0
a2p1 dp addr 0xbfc8d2cc dp contian 23911a0
a2p ap addr 0xbfc8d2d8 ap contian 0x23919c0
a2p dp addr 0xbfc8d2cc dp contian 0x23919c0
main2 fap addr 0xbfc8d308 fap contian 0x23919c0
gyx@gyx-virtual-machine:~$ gcc -o mec mec.c ^C
gyx@gyx-virtual-machine:~$ cat mec.c
#include <stdio.h>
#include <stdlib.h>
int a2p( char **dp)
{
printf("a2p1 dp addr %p dp contian %x\n",&dp,*dp);
char *ap =NULL;
ap =(char *)malloc( 1024);
free(*dp);
*dp =ap;
printf("a2p ap addr %p ap contian %p\n",&ap,ap);
printf("a2p dp addr %p dp contian %p\n",&dp,*dp);
return 1;
}
int main()
{
char * fap =NULL;
fap =(char *)malloc( 1024);
printf("main fap addr %p fap contian %p\n",&fap,fap);
a2p(&fap);
printf("main2 fap addr %p fap contian %p\n",&fap,fap);
free(fap);
printf("");
}
gyx@gyx-virtual-machine:~$ vim mec.c
gyx@gyx-virtual-machine:~$ gcc -o mec mec.c
mec.c: In function ‘main’:
mec.c:23:9: warning: zero-length gnu_printf format string [-Wformat-zero-length]
23 | printf("");
| ^~
gyx@gyx-virtual-machine:~$ ./mec
main fap addr 0xbfa190e8 fap contian 0x1fb01a0
a2p1 dp addr 0xbfa190ac dp contian 0xbfa190e8
a2p ap addr 0xbfa190b8 ap contian 0x1fb09c0
a2p dp addr 0xbfa190ac dp contian 0x1fb09c0
main2 fap addr 0xbfa190e8 fap contian 0x1fb09c0
二级指针的理解
最新推荐文章于 2024-09-11 11:42:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)