-
Passing arguments.
When I want to pass multiple arguments to a function, and do the same thing to all of these arguments, is there an easy way to do this?
Code:
void vul(ruiten[4], harten[4], klaver[4], schoppen[4])
{
int a;
for (a = 0; a < 4; a++)
{
array[a] = a;
}
return;
The idea is that the function vul fills, every array with numbers from 0-3.
It won't work this way, but is there a way? Or am I being completely confused right now?
Thank You.
-
You could just write a function to perform operation X on the array you pass as argument and call that function n times.
(So if you wanted a function to do Y with n arrays, write a function that does this operation on an array passed as argument and call this function for every array.)
Also note that all arguments must have types.
-
I don't really understand the part: "write a function that does this operation on an array passed as argument"
How can I make a calculation with an array, that is array independant. I mean that it doesn't matter which array you give it.
-
You can't make it independent. Just see it as breaking the original function into parts. Specialized parts.