Function to return an array of integer

Hi all,

I am trying to create a function that return an array of integer based on the char parameter pass into the function. I.e.

func_a(char * str)
{
example str is equal to "1,2,3,4"
return an array of integers of 1,2,3,4
}

Please advise

regards
dwgi32

The C language does not let you return an array unless you either

(a) just return a pointer to the type of whatever the array is, and you have to allocate that array, eg you return an "int *".

(b) use a typedef to define the array, and then return that..

typedef int array_int3[4];

array_int3 func(...)
{
array_int3 ret={1,2,3,4};

     return ret;
}

Hi Potter,

Tks a lot.