动态数组

1881阅读 0评论2011-12-08 bo_00
分类:C/C++

  1. #include <stdio.h>
  2. #include <stdlib.h>

  3. typedef struct _my{
  4.   char a;
  5.   int b[]; //动态数组
  6. } my;

  7. int main()
  8. {
  9.     int c = 5;  //变量
  10.     my *p;
  11.     printf("struct size %d %d\n",sizeof(my),sizeof(int));
  12.     p = (my*)malloc(sizeof(my) + c * sizeof(int)); //内存空间申请

  13.    return 0;
  14. }
上一篇:Linux多线程编程实例 [转→改]
下一篇:数据翻转(镜面翻转)