An example of second rank pointer struct data

1 #include <stdio.h>
2
3 void main()
4 {
5     struct cc{
6     int a;
7     char *ap;
8     };
9     struct cc c;
10     c.a=100;
11     c.ap="abcdefg\n";
12
13     printf("%d;%s",c.a,c.ap);
14
15     struct cc * cp=&c;
16     printf("%d;%s",cp->a,cp->ap);
17
18     struct cc ** cpp=&cp;
19     printf("%d,%s",(**cpp).a,(**cpp).ap);
20     printf("%d,%s",(*cpp)->a,(*cpp)->ap);
21 }

结果:
omycle@omycle-desktop:~/network$ ./test
100;abcdefg
100;abcdefg
100,abcdefg
100,abcdefg

评论

此博客中的热门博文

提交了30次才AC ---【附】POJ 2488解题报告

n个进程共享m个资源得死锁问题证明