Calling a function in main() program

How to call following function returning array into main() program and print each values of a array[3]?

float arr(float degF)
{
float fC;
fC = ((degF - 32)*(5.0/9.0));
float fK;
fK = (((degF - 32)*(5.0/9.0))+273.15);
float fR;
fR = (degF+459.67);
float arry [3] = { };
arry [0] = fC;
arry [1] = fK;
arry [2] = fR;
float result = arry[3];
return result;
}
This function does not return an array; it returns a single float. You are also accessing out of bounds memory when you assign to it on the 2nd to last line.

If you want to return an array you will have to deal with dynamically allocating and deleting memory yourself. There is more information in the tutorial here on dynamic memory I believe.
Topic archived. No new replies allowed.