struct definition

Please help me understand this piece of code.
The first structure is easy, but the second one I can't understand at all.
What does it mean struct Address rows[MAX_ROWS]. Does it have any relaton to the first structure. And in the third structure as I understood is pointer to the second one. I'll appreciate you help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct Address {
    int id;
    int set;
    char name[MAX_DATA];
    char email[MAX_DATA];
};

struct Database {
    struct Address rows[MAX_ROWS];
};

struct Connection {
    FILE *file;
    struct Database *db;
};
1) struct isn't mandatory int this case. You can write Address rows[MAX_ROWS] and it will work. Notice how it is similar to int foo[BAR].
It is an array of MAX_ROWS entries of type Address.
Third structure has a pointer to Database type variable.
Example of use:
1
2
3
Connection c;
c.db = new Database;
(c.db->rows)[7].id = 500;
Ok. I understood about your first sentece, but I have one more questoin. That is like a simple declaration Address rows[MAX_ROWS], but after it struct Database will be
1
2
3
 struct Database {
    Address rows[MAX_ROWS];
};

or
1
2
3
4
5
6
7
struct Database {
    Address rows[MAX_ROWS];
    int id;
    int set;
    char name[MAX_DATA];
    char email[MAX_DATA];
};


And honestly I didn't completely find out about (c.db->rows)[7].id = 500;
Sorry for my silly. I appreciete your help.
As I understood rows[MAX_ROWS] is an array of structures Address. Am I right?
Correct.
Topic archived. No new replies allowed.