I am trying to create a static array where the length of the array could differ. I am doing this so that i can return the array from a function without using pointers.
I have tried:
void arrExample1(int size){
#define len size
satic int arr[len];
}
void arrExample2(int size){
enum { len = size };
static int arr[len];
}
Neither of these have worked and I am at a loss of what I should do next. Can I get some advice or pointed in the correct direction?
mallocinstead (andfreeit later) or let the caller pass a pointer to an array of the correct size to the function. The latter approach allows the caller to choose where the memory resides.