Returning Values

Can a function return a whole array?
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.
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
Topic archived. No new replies allowed.