首页 > 其他 > 详细

指针和结构体补充

时间:2016-08-05 19:40:36      阅读:162      评论:0      收藏:0      [点我收藏+]

 

1. 

 1 #include "stdio.h"
 2 #include "stdlib.h"
 3 
 4 struct sector{
 5     char *pstr;
 6     int strlen;
 7 };
 8 
 9 struct arry{
10     struct sector *parr;
11     int length;
12 };
13 
14 
15 int main()
16 {
17     struct arry *p = malloc(sizeof(struct arry));
18     p->length = 10;
19     p->parr = malloc(sizeof(struct sector)*p->length);
20     
21     p->parr[0].strlen = 10;
22     p->parr[0].pstr = malloc(p->parr[0].strlen);
23     
24     printf("zhangliang\n");
25     return 0;
26 }

 

指针和结构体补充

原文:http://www.cnblogs.com/mrsandstorm/p/5742508.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!