首页 > 代码库 > 柔性数组--变长数组
柔性数组--变长数组
int init_Department(manager *pt)
{
assert( NULL != pt && pt->p != NULL) ;
pt->p->Manager = 10;
pt->p->PM =100;
pt->p->ProgrammerNo[0]=10000;
pt->p->ProgrammerNo[1]=10001;
pt->p->ProgrammerNo[2]=10002;
pt->p->ProgrammerNo[3]=10003;
pt->p->ProgrammerNo[4]=10004;
return 0;
}
typedef struct _Department
{ int Manager; int PM; int ProgrammerNo[0]; }Department; typedef struct _manager{ Department *p;}manager; int main(void) { printf("sizeof(Department)=%d\n",sizeof(Department)); Department *pt = NULL; int Num = 5; pt = (Department *)malloc(sizeof(Department) + sizeof(int) * Num); pt->ProgrammerNo[0] = 006; pt->ProgrammerNo[1] = 99; manager *ptr = ( manager *)malloc(sizeof(manager)); ptr->p=(Department*)malloc(sizeof(Department)+sizeof(int)*5); init_manager (ptr);}
柔性数组--变长数组
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。