Return pointer from functions in Objective-C

As we have seen in last chapter how Objective-C programming language allows to return an array from a function, similar way Objective-C allows you to return a pointer from a function. To do so, you would have to declare a function returning a pointer as in the following example:

int * myFunction()
{
.
.
.
}

Second point to remember is that, it is not good idea to return the address of a local variable to outside of the function so you would have to define the local variable as static variable.

Now, consider the following function, which will generate 10 random numbers and return them using an array name, which represents a pointer, i.e., address of first array element.