Returning Values

Feb 28, 2011 at 6:53am
Can a function return a whole array?
Feb 28, 2011 at 6:58am
When entire arrays are passed to a function, they are passed by reference, because the array name is actually the pointer to the elements in memory - so any changes to the array in the function actually changes the array.

If you just pass an individual element it is passed by value, and the individual element value can be returned by a function.
Feb 28, 2011 at 7:48am
Can a function return a whole array?
No.

You would also have problems writing a function prototype
that tries to return an array.

1
2
//attempting to write a function that returns an array
char func1 () []; //Compiler arror - function returning array 




Last edited on Feb 28, 2011 at 7:49am
Topic archived. No new replies allowed.