give a sample example of it.
How to define a function that returns a pointer to an array?
Collapse
X
-
-
your function declaration returns pointer to an integer variable not a 'pointer to an int array'.Comment
-
They are in fact the same, please do click on the link Banfa gave you.
In both C and C++ when you refer to an array by using the address of element 0, you lose the number of elements and end up with only the address of element 0. This is called decay of array and because of this you also need the number of elements.
Also, in C and C++, functions have a return type which can be a) a type or b) a pointer to a type. The most you can return is the address of an element of the array.Comment
Comment