123456789101112131415161718192021222324252627282930313233343536373839404142434445
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "pension.h" // basic struct for the 3 types struct _DOG1 { int dog_id; char* dog_name; char dog_gender; char* first_name; char* family_name; char* cell_phone; }; struct _DOG2 { DOG1* dog_type2; char* date; }; struct _DOG3 { DOG1* dog_type3; char* date; int days_num; }; struct _PENSION { DOG1* p1; DOG2* p2; DOG3* p3; }; PENSION* CreatePension() { DOG1* arr1; DOG2* arr2; DOG3* arr3; arr1 = (DOG1*) calloc(MAX_DOGS, sizeof(DOG1)); arr2 = (DOG2*) calloc(MAX_DOGS, sizeof(DOG2)); arr3 = (DOG3*) calloc(MAX_DOGS, sizeof(DOG3)); if ((arr1 == NULL) || (arr2 == NULL) || (arr3 == NULL)) return NULL; PENSION* p; p->p1 = arr1; p->p2 = arr2; p->p3 = arr3; return p; }
p->p1 = arr1;