An example of second rank pointer struct data

原创文章,转载请注明出处.转载自: Li Haifeng's Blog
本文链接地址: 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=”abcdefgn”;
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

From Li Haifeng's Blog, post An example of second rank pointer struct data

Post Footer automatically generated by wp-posturl plugin for wordpress.

分享到: