Originally Posted by
tempster09
I have rethought variodic functions, is there anyway to mimic the
Of course. I kind of thought this is where you were at, I just didn't want to seem patronizing and say maybe you do not understand C that well yet?
char *argv[] is a string literal array:
Code:
char *example[] = {"one", "two", "three"};
You shouldn't alter this after declaration tho, so it's usefulness is somewhat limited.
But consider a dynamic pointer array, char **example.
Code:
char **example = malloc(3*sizeof(char*));
This can be resized. Each member is a pointer:
Code:
example[1] = malloc(32);
Of course, if this were a struct or typedef array, you would just go:
Code:
example = malloc(3*sizeof(mystruct*));
example[1] = malloc(sizeof(mystruct));
So witness, you have a dynamic array of structs. This is the kind of thing you can put into initialization or allocation/deallocation functions. And:
Code:
void some_function(int len, mystruct **array);
Guess what? If "len" is like argc -- that is, the number of pointers in "array", you now have an adaptable arrangement like argc, argv.
Hope this is what you were looking for.