c语言中结构体的嵌套例题,C语言嵌套结构体问题

1,C语言嵌套结构体问题person 改成PersonC++是驱分大小写的
2 , C语言结构体嵌套typedef structint x;int y;}point;typedef structpoint *ptFirst;point *ptSecond;}rect;上面两个结构我的编译器没有报错贴一下代码 。struct class two_classes[2];two_classes[i].a[j] = ...;另外,class中的数组a的长度需要一个常量这个我也不太懂【c语言中结构体的嵌套例题,C语言嵌套结构体问题】
3,c语言共用体里面嵌套有结构体求详解高分悬赏谢谢共用体就是享用同一块内存在此例中e的大小为最长元素的大?。?也就是结构体out的大小,共两个int , 假设此处int为4字节e.c和e.d和e.out.a占用同一块内存,即低4字节的内存 , a.out.b占用高4字节内存然后e.c=1;e.d=2;e.c和e.d和e.out.a都为2e.out.a=e.c*e.d = 2*2 = 4;那么e.c和e.d和e.out.a都变成了4e.out.b=e.c+e.d = 4+4 = 8typedef structint x;int y;}point;typedef structpoint *ptfirst;point *ptsecond;}rect;上面两个结构我的编译器没有报错贴一下代码 。
4,c语言结构嵌套首先是一个年月日的结构体 struct birthday{int year; int month; int date;};接下来是学生struct stu{ char num[20]; char name[20]; char sex; struct birthday birthDay;};这样就可以了typedef struct{int year;int month;int day;}date;typedef struct{int num;char name[20];char sex;date birthday;}student;struct int num;char name[20];bool sex;structint year;int month;int date;}birthDay;};5 , C语言结构体的嵌套问题scanf输入格式有问题#include <stdio.h>#include <stdlib.h>#include <malloc.h>#include <string.h>struct course char name[10]; int score; int credithour;};typedef struct student char name[10]; struct course s[5]; int average; struct student *next;}STU;void Create(STU *L) int i,sum; STU *p,*s=L; while (1)p=(STU *)malloc(sizeof(STU));s->next=p;printf("name\n");scanf("%s",p->name);if (strcmp(p->name,"exit")==0)s->next=NULL;break;}s=p;for (i=0; i<5; i++)printf("course\n");scanf("%s",p->s[i].name);printf("course score\n");scanf("%d",&p->s[i].score);//注意scanf的输入格式printf("course credithour\n");scanf("%d",&p->s[i].credithour);//同上sum+=p->s[i].score;}p->average=sum/(i+1); }} void main() STU *L; L=(STU *)malloc(sizeof(STU)); L->next=NULL; Create(L);}

    推荐阅读