Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 对于此类数据,我应该使用什么数据结构?_C_Arrays_Data Structures_Struct_Typedef - Fatal编程技术网

C 对于此类数据,我应该使用什么数据结构?

C 对于此类数据,我应该使用什么数据结构?,c,arrays,data-structures,struct,typedef,C,Arrays,Data Structures,Struct,Typedef,我的数据如下所示: University { Society { LibrariesList Library { Name: "Central Library" BuildingNumber: 23b Address { Electronic Address: "blahblah blah"

我的数据如下所示:

University {

    Society {

        LibrariesList 
            Library {

                Name: "Central Library"
                BuildingNumber: 23b
                Address {
                    Electronic Address: "blahblah blah"
                    Phone: 12345677
                    Street Address {
                        Num:4
                    }
                }
                Code:43

            }
        DepartmentsList:1

    }

}

我必须将它存储在我的C程序中。我是C语言的初学者,不知道用哪种数据结构来做这类事情。那么我应该使用什么样的数据结构呢?

我想您正在寻找这样的数据结构

struct stradr
{
      int num;
};

struct add
{
      char electronicAddress[100];
      unsigned int phone;
      struct stradr streetAddress;
};

struct lib
{
      char name[100];
      char BuildingNo[5];
      struct add address;
};

struct libList
{
       struct lib library;
       int code;
};

struct scty
{
        struct libList librarieslist;
        int departList;
};

struct unvrsty
{
        struct scty society;
} university;

作为c中的数据结构,我认为c不能同时处理字符串和整数。可能有更好的方法,但考虑到您说自己是初学者,实现起来太复杂了:)

您不能将其存储在名为libraries的动态数组中吗?一旦你有了这个列表,你打算用它做什么?仅仅显示数据格式不足以决定使用什么样的数据结构。如何使用这些数据同样或更为重要。插入的频率是多少?删除的频率是多少?多久进行一次查找?查找是连续的还是随机的?等等@kaylum说真的?你真的要和他谈谈C语言中的哈希图、红黑树等吗?他是个初学者。他正在学习编程,而不是开发一款可扩展的行业应用程序。所以结构和向量。代表他回答你的问题:这些数据将被用作学习C的基础知识的借口。@bolov谢谢你。
struct libList
a list的原因是什么?@alk主要是因为该库位于librarieslist的标题下,我相信可能会发生变化,所以我假设它是一个列表。只是一个故障保护,尽管是多余的。