Quote Originally Posted by leo2008 View Post
I have the below code which has issue with double return value. How can I fix it?

Code:
double *funct( double i )
{
           double result = 2.0 * i;
           return &result;
}
It's hard to answer because no-one would write a function to muliply a real value by two. It must be placeholder code.

If you are calculating one value, return it as a "double" (not a double *). If you are calculating several values, but only a small number, then pass in pointers to the values and set them in the function. If you are calculating a long list of values, or if the number of values isn't fixed (e.g. a list of prime factors for an integer), then allocate memory with malloc, fill it with the values, then return it. Usually you will also have to pass in a count varibale via a pointer.