Since you're new to functions, a good example might be an exercise in code reuse. Here, we just use a generic 'copy_if' function to do all the work.
Code:
#ifndef BOOL
typedef int BOOL;
#endif
int copy_if(
int destination[],
int * dest_length,
int source[],
int src_length,
BOOL (*criteria)(int)
)
{
int s, d = 0;
for(s = 0; s < src_length; ++s)
{
if( criteria(source[s]) )
{
destination[d++] = source[s];
}
}
if(dest_length != NULL) *dest_length = d;
return d;
}
BOOL is_even(int number)
{
return number % 2 == 0;
}
BOOL is_odd(int number)
{
return !is_even(number);
}
BOOL is_anything(int number)
{
return 1;
}
int main()
{
const int sz = 6;
int array[sz] = {63, 12, 10, 11, 8, 77};
int even[sz], ez;
int odd[sz], oz;
copy_if(even, &ez, array, sz, is_even);
copy_if(odd, &oz, array, sz, is_odd);
copy_if(array, NULL, even, ez, is_anything);
/* we know &array[ez] is the next free space */
copy_if(&array[ez], NULL, odd, oz, is_anything);
for(int i = 0; i < sz; ++i)
printf("%d ", array[i]);
return 0;
}