Hi,
Returning a simple array of data is usually handled by directly returning the data as the return value. But what if I want to return several arrays? I need a pure C solution, so references can't be used.
The only way I have come up with is following, but it doesn't seem elegant to me:
void returnSomeArrays(float** array1,int* array1Length, int** array2,int* array2Length)
{
if (array1Length[0]!=-1)
{
array1[0]=new float[23234];
array1Length[0]=23234;
}
if (array2Length[0]!=-1)
{
array2[0]=new int[99];
array2Length[0]=99;
}
}
and then I would use the function as following:
float* array1;
int* array2;
int array1Length=0;
int array2Length=0;
returnSomeArrays(&array1,&array1Length,&array2,&array2Length)
However I don't like the notation and I believe there should be a simpler way of achieving what I want?