Monday, December 14, 2009

Array as a function parameter...

This can be kinda tricky at first, but really it is just a matter of leveraging the convergence of the zero element of an array and a pointer of the same type.

so you have
int myInts[] = {1,2,3,4,5}
that needs to be passed into a function

so you just prototype the function:
foo(int* input);
and to use it just pass in the array:
foo(myInts);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.