how do i a function to create an array of n amount of structures dynamically and then to return a pointer to array. So far I have ....
but i dont think will work. pls help!Code:typedef struct{ char *name; int day_of_birth; int month_of_birth; int year_of_birth; } data_t; data_t create_data_t_array(int n) { int i; data_t *ptr; ptr = malloc(sizeof(*ptr)); for (i = 0; i < n; i++) { ptr[i] = malloc(sizeof(*ptr)) } return ptr; }



LinkBack URL
About LinkBacks


