filmov
tv
C++ Programming [3] - Array Passing

Показать описание
This tutorial will show you how to pass an array and all of it's contents to another function.
Remember when passing an array all you need to do is specify it's name, for example:
int array[ ] = {1,2,3,4};
functionPass(array); // sends the address of the array to the function
Now to receive this array you must have the following header:
void functionPass(int array[ ]){
array[1] = 45; // you now have access to it's members
}
Keep in mind you have to cast this also:
void functionPass(int [ ]);
Remember when passing an array all you need to do is specify it's name, for example:
int array[ ] = {1,2,3,4};
functionPass(array); // sends the address of the array to the function
Now to receive this array you must have the following header:
void functionPass(int array[ ]){
array[1] = 45; // you now have access to it's members
}
Keep in mind you have to cast this also:
void functionPass(int [ ]);