If I have the following C struct:
struct group_of_pointers {
double *p1, *p2, *p3;
} *pointers;
Now, I want to allocate n spaces (each with sizeof double) to pointers->p1, pointers->p2, pointers->p3. How do I do this? Do I have to allocate any space to the pointer to the structure 'pointers' itself?
Thanks.
ETA: Related question: The reason I need this struct is because I want to return 3 variable length arrays from a function. Should I just do
void foo(const double* const input, double *output1, double *output2, double *output3)
or should I do
struct group_of_pointers *foo(const double* const input)
The former looks a bit confusing with input and output all bundled together. But is it just the way C is?