Could someone tell me if this answer is correct!? I'm not sure about the allocation of the second struct:
struct dyn_array my_array = malloc(sizeof(struct dyn_array) + 100 * sizeof(int));
Shouldn't my_array
be a pointer, like this:
struct dyn_array *my_array = malloc(sizeof(struct dyn_array) + 100 * sizeof(int));