So i been studying C, and got to structs and saw this example online:
Code:
#define MAX_DATA 512
#define MAX_ROWS 100
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;
};
My question is why do people create structs that contain others?
I understand Address, now Database it has inside struct Address rows[MAX-ROWS], this means that its creating an array that contains id,set,name,email and this values are stored in the array in that way
id | set | name | email < ROW#1 (and it has a max of 100 rows)
Ten Connection includes this array(rows) and a file name
correct??