Array of Structures with Unique Structures? March 07, 2010 05:10AM | Registered: 14 years ago Posts: 121 |
Re: Array of Structures with Unique Structures? March 07, 2010 06:57AM | Registered: 15 years ago Posts: 703 |
typedef struct { string First; string Last; int Account; int *Contacts; } client_type;
typedef struct { int Country; int Area; int Phone; } contact_1; typedef struct { string Street; string City; string Province; string Country; } contact_2; typedef struct { string Address; } contact_3; typedef struct { string First; string Last; int Account; contact_1* pcontact1; contact_2* pcontact3; contact_3* pcontact3; } client_type; client_type clients[200]; // Define array for 200 clients contact_1 *temp1 = malloc(sizeof(contact_1)); contact_2 *temp2 = malloc(sizeof(contact_2)); contact_3 *temp2 = malloc(sizeof(contact_3)); clients[0].First="Joe"; // Populate first client clients[0].Last="Brown"; clients[0].Account=12345; // access to all clients[0]->pcontact1 = temp1; clients[0]->pcontact2 = temp2; clients[0]->pcontact3 = temp3; clients[0]->pcontact1->Address="JoeBrown@Hotmail.Com"; // Populate the contact info ..... ..... free(clients[0]->pcontact1); free(clients[0]->pcontact2); free(clients[0]->pcontact3);
Re: Array of Structures with Unique Structures? March 07, 2010 10:33AM | Registered: 14 years ago Posts: 121 |
Re: Array of Structures with Unique Structures? March 08, 2010 08:38AM | Registered: 14 years ago Posts: 686 |
Re: Array of Structures with Unique Structures? March 08, 2010 11:02AM | Registered: 14 years ago Posts: 121 |