I need help in the Syntax of this

I need help please anyone
How do we write float array return type function? I have the 3 values as floats in the function right now I can read them through the serial port. But I am not sure how to pass them to the void loop.
Also I would appreciate telling how to call the function there.

Float array[3] function (arguments)
{
return float array[3]
}

My advice is to pass the array by reference, like this:

void func (float (& args) [3])
{
  args [0] += 1;
  args [1] *= 2;
  args [2] /= 3;
}

void setup ()
  {
  float foo [3] = { 5, 6, 7 };
  func (foo);
  }
void loop () {}

My advice is to pass the array by reference, like this:

Yep. Functions can not return arrays.

But an array is just an alternative notation for pointer arithmetic, and arrays are normally passed by reference anyway...

So the following would work the same as Nick's example, with more obvious syntax:

void func( float args[3] )
{
  args[0] += 1;
  args[1] *= 2;
  args[2] /= 3;
}

void setup()
{
  float foo[3] = { 5, 6, 7 };
  func( foo );
}

void loop()
{
}

This also reinforces the point that you should be careful not to alter the values in an array passed to a function in place, unless you want those changes to affect the array in the calling function as well.

Yes, you are right. I wonder what put that idea into my head? Thanks for the clarification.

In my defense, the earlier suggestion makes it clearer that we are expecting the array to be modified.

I am already in a function

I am reading the values serially from matlab using xbees.
The I am calling a function that has chararray as argument which separates the characters to 3 float values.
I want to pass back those values to the loop so I can use them.
But I am only allowed return

void getMeSomeFloats(char *buffer, float &servoVal, float &pwmVal, float &pressureVal)
{
   servoVal = ???;
   pwmVal = ???;
   pressureVal = ???;
}

how to get these values in the void loop.

I dont get it pauls do you mean like this

void(inData[])
{
servoFloat= x;
pwmFloat= y;
pressure= z;
getMeSomeFloats(inData,servoFloat,pwmFloat,pressureFloat);

}
void loop()
{
   void getMeSomeFloats(char *buffer, float &servoVal, float &pwmVal, float &pressureVal)
  {
   servoVal = ???;
   pwmVal = ???;
   pressureVal = ???;
   }

}[\code]

No, I doubt it. Try this please:

http://www.cplusplus.com/doc/tutorial/

then I guess the only way would be to write 3 functions each time returning one of the values
do you think it is ok this way

Hi,
here is another solution:

float *ReturnArray()
{
   static float arr[3]; // must be static!

   arr[0] = 1.1f;
   arr[1] = 2.2f;
   arr[2] = 3.3f;

   return arr;
}

void loop()
{
   float *v = ReturnArray();
   // Use v as an array:
   float sum = v[0] + v[1] + v[2];
}