这个是最常用的数据结构,也就是说的封装。
digraph collectstruct{
deviceName;
toolName;
gameName;
muralName;
};
// 集合结构 : 缺点对数据的访问不能使用 for循环,只能一个个通过名字取得到数据
#include <windows.h> #include <stdio.h> // 下面可以想象我家的房间的样子 // 我的家结构 内存是立体的 struct Aggregation_DataStruct { char* deviceName; char* toolName; char* gameName; char* muralName; }; static struct Aggregation_DataStruct DataStuct_Aggregation = { .deviceName = "手机", .toolName = "风扇", .gameName = "穿越火线", .muralName = "奥黛丽赫本" }; int main() { //while (1) { //集合结构 离散结构 不能使用for循环 通过一个首地址取得的各个元素的内容 for (int i = 0; i < 4; i++) { printf("DataStuct_Aggregation is %s\n", ((DataStuct_Aggregation.deviceName+i))); } //只能下面操作 printf("deviceName is %s\n", DataStuct_Aggregation.deviceName); printf("toolName is %s\n", DataStuct_Aggregation.toolName); printf("toolName is %s\n", DataStuct_Aggregation.gameName); printf("muralName is %s\n", DataStuct_Aggregation.muralName); } while(1); }