void split_up_array( int *a, int n, int *w, int *x, int *y, int *z ) {
? ? while ( n > 0 ) {
? ? ? ? *w++= *a++, --n;
? ? ? ? if ( n > 0 ) *x++= *a++, --n;
? ? ? ? if ( n > 0 ) *y++= *a++, --n;
? ? ? ? if ( n > 0 ) *z++= *a++, --n;
? ? }
}
Note that I changed "int a[]" parameter to "int *a", since your NOTE says to only use pointer parameters and pointer notation.
Here are the prototypes that we must use:
void initialize_array(int[],int);
void split_up_array(int [], int, int *, int *, int *, int *);
void print_array(int[], int);
And the task is this:
We are to create a function that takes an initialized array and creates 4 smaller arrays. The part with initialization and printing I already did. So, suppose the main array has 52 elements and they are matching the index of the array. Eg. 0-51. So, after we create 4 new arrays, we need to copy the elements of the old array to the new ones like so:
Element 0 of the original array should be in child 0, element 1 in child 1, element 2 in child
2, element 3 in child 3 and element 4 in child 0, and so forth.
We then must display the original array before making the function call to split the arrays, then display all five arrays at the end.
NOTE: Must use ONLY pointer parameters and use pointer notation (not subscripts) to move through the elements of arrays.