help with pointers

Hi I a function that splits an array of chars into tokens and then converts each token into a float number, the code is the following:

float* splitContent(char info[])
{ char *pch;
float fdata[6];
float *floatdata;
floatdata = fdata;
int i=0;
pch = strtok (info," ");

while ((pch != NULL) && i < 5)
{ *floatdata = atof(pch);
printf ("%1.8f \n",fdata[i]);
floatdata++;
i++;
pch = strtok (NULL, " ");
}
return floatdata;

}

I put a prinf inside the method splitContent and I the method works properly.
Then, somewhere else in my code I call the method above using the following code:

float data[6];
float *split = splitContent("-0.14433155 -0.04073187 0.078306405 0 0 0");
for (int i=0; i<6; i++)
{ data[i]= *split;
printf("%2.8f \n",data[i]);
split++;
}

I want to retrieve the content of my array back, but the code above does not
work to do that, can somebody help me please, I have already read about pointers
but I am still a lot confused. Thank you in advance for your help.

[code] "Please use code tags" [/code]
The return value of your function makes no sense.
You could pass the array to be filled to the function
float* splitContent(char info[], float data[]); However you will need to reserve enough space in the client code. (or use vector)
Topic archived. No new replies allowed.