> ~ Online tutorial


Arrays as Parameters
What happens if we want to pass an array as a parameter? Does the program copy the entire array into local storage? The answer is no because it would be a waste of time and memory. Arrays can be passed as parameters, but only as variable ones. This is a simple matter, because the name of the array is a pointer to the array. The Game of Life program above does this. Notice from that program how the declarations for the parameters are made.
main ()

{
char array[23];

function (array);

.....
}

function (arrayformal)

char arrayformal[23];

{
}

Any function which writes to the array, passed as a parameter, will affect the original copy. Array parameters are always variable parameters

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: