由于结构体是不同类型数据结构的集合,那么一个结构体的成员可以是基本数据类型,也可以是另外一个结构体类型。那么复合类型的结构体又有什么特征呢。
先看一个例子:
#include <stdio.h>
struct xuzhina_dump_c05_s3_2_sub
{
char a;
short b;
};
struct xuzhina_dump_c05_s3_2
{
int c;
long d;
struct xuzhina_dump_c05_s3_2_sub sub;
};
int main()
{
struct xuzhina_dump_c05_s3_2 test;
scanf( "%c, %hd, %d, %ld", &test.sub.a, &test.sub.b,
&test.c, &test.d );
return test.c + test.d;
}
更多内容请关注微信公众号“debugeeker", 链接为https://mp.weixin.qq.com/s/QNrBdXrlhghGMfNfKsBLdA