I want to create a function that will accept input from the user and return the input, to be used for further calculation. I know how to accept and return with integers as parameters , but how do i do it with arrays?
EDIT: Let me make it clear.
Suppose there is an array of numbers arr. Now, i want a function that accepts the input from the user, and return the array for further manipulation.
For example, if the array is arr, then i should call a function and accept the values from the user. Then, i should return the imputed values and print the same. How can i do this.
If you do not know the size in advance, then you have to allocate memory for the array dynamically. In that case you would pass a pointer (that points to the memory location) between functions. (And size too).
Pointer to the first element of array is passed.
Arrays passed to functions are reduced to pointer.
After determining the type of each parameter, any parameter of type “array of T” or “function returning T” is adjusted to be “pointer to T” or “pointer to function returning T,” respectively. C++ standard 184.108.40.206