Is it possible to create a function which will take any number of structures as an argument? For example, what if I wanted depending on the circumstances to pass a structure named astruct, or bstruct, or cstruct, to the function? Sort of like this: myfunc(char * str, struct astruct *as) From googling, it always appears that one specific structure is passed to the function.
Quote: Is it possible to create a function which will take any number of structures as an argument? For example, what if I wanted depending on the circumstances to pass a structure named astruct, or bstruct, or cstruct, to the function? What are you really trying to do? I'm having trouble coming up with a case where the Right Answer is something other than "write a different function for each struct", possibly in the degenerate case of "use a single struct for all of the options".
This could also done. A void * argument will accept a pointer to any data type. However, it could just as easily be passed a char[] or an int as a struct, so if you want to catch those possibilities, this wouldn't work for you. And there's no way to retrieve the original type directly -- it could be done with an extra parameter and selection logic.