简体   繁体   中英

What data structure should I use for this kind of data?

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?

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM