我应该为这种数据使用什么数据结构?

时间:2023-02-01 20:02:25

My data looks like this:

我的数据如下所示:

University {

    Society {

        LibrariesList 
            Library {

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

            }
        DepartmentsList:1

    }

}

I have to store it in my C program. I am a beginner in C and don't know which data structure to use for this kind of thing. So what data structure should I use?

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

1 个解决方案

#1


1  

I think you are looking for something like this.

我想你正在寻找这样的东西。

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;

As of a data structure in c, I don't think that C can handle strings and Integers together. There might be better ways, but that would be too complicated to implement, considering you said that you are beginner :)

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

#1


1  

I think you are looking for something like this.

我想你正在寻找这样的东西。

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;

As of a data structure in c, I don't think that C can handle strings and Integers together. There might be better ways, but that would be too complicated to implement, considering you said that you are beginner :)

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