So far, you have seen two ways to write the main
readData
combination:
main
. The address of the memory
representing the array is assigned to a variable in main
. Then,
you hand over the address to readData
, where it is assigned to a
parameter. On return, the address is handed back, and again is assigned to
the variable in main
from whence it came.
main
. The address of the memory
representing the array is assigned to a variable in main
. Then,
you hand over the address to readData
, where it is assigned to a
parameter. Nothing is returned, but the changes to the array stick,
because only the address is copied on entering readData
, and the
array elements are not copied.
There is another alternative:
main
. Thus, there is no
array to hand to readData
. Instead, you create the array in
readData
, and hand it back as the value of readData
.