answersLogoWhite

0

How an array passed to a function?

Updated: 8/19/2019
User Avatar

Wiki User

11y ago

Best Answer

Arrays should be passed by reference or by pointer, never by value (passing by value passes a copy of the reference, not the reference itself). The array length should also be passed to the function (by constant value) to prevent buffer overflows. Alternatively, in object-oriented languages, arrays can be wrapped in a class of object. Since the array is a member of the class, it doesn't need to be passed to the member methods, thus the function can become a member method of the class itself or a derivative of the class. Or the object containing the array can be passed to external functions by reference.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How an array passed to a function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can and array be passed to a funaction?

try this: <function-name> ( <array-name> )


When an array name is passed to function in c?

It 's address is received by the function . that any changes in the value of array elements in the function will result in actual change.


What happen when a c program passes an array as a function argument?

When an array name is passed as a function argument, the address of the first element is passed to the function. In a way, this is implicit call by reference. The receiving function can treat that address as a pointer, or as an array name, and it can manipulate the actual calling argument if desired.


What does array map do in php?

The array_map function in PHP loops over each elements of the passed array(s), and runs the given function. It then returns a new array that contains the values returned by each call to the given function.


How do you pass a 2D array in a functions?

if you were to call a function you would write it as: function(array[][], int pretend, double pretend2); arrays will always be passed by reference, not by value.


How is an array name interpretedwhen it is passed to a function?

An array is still an array, regardless of how you pass it into functions. It is still an array-type variable at the beginning of a function. However, the function itself may manipulate the array by "imploding" it into a string with a delimiter, using array values with only specific keys, and such.


Argument Array in java script?

There is an arguments object in JavaScript. This object is treated much like an array (but it's not actually an array.)You can however reference the arguments passed to a function via this array. For instance, if we call a function like so:exampleFunc('Tom', 15, 'potato');Then we can access the value of Tom at the local variable arguments[0].


What is the array function in CAD?

there r 2 types of array in cad - rectangular array and polar array...........


Why the array is starting from zero?

By design; it makes the compiler's work easier. 1-based array's addressing-function: Address (array, index) = Address (array) + (index-1)*Elemsize(array) 0-based array's addressing-function: Address (array, index) = Address (array) + index*Elemsize (array)


Simple non-array variables are usually passed to methods by?

Simple non-array variables are usually passed to methods by value.


What is an Access function for an array?

.


What is the purpose of AND array?

AND array is used for developing digital circuit it is used in PLA programmable logic array and PAL programmable array of logic to implement the function. the number of and array will depend on how long you has function to be implemented.These are Digital circuits.