Asume that you define function like this:
than you can pass to function different number of arguments. Okay its only one real argument but void * can point to array of arguments.
Code:
#include <stdio.h>
int foo(void *);
int main()
{
char arg1[] = {2, 1, 2};
char arg2[] = {3, 1, 2, 3};
printf("%d\n", foo((void *) arg1));
printf("%d\n", foo((void *) arg2));
return 0;
}
int foo(void * arg)
{
int acc=0, i;
char * tmp = arg;
/* first element of array is num of arguments */
for (i=0; i<tmp[0]; i++)
{
acc += tmp[i+1];
}
return acc;
}