c - Can I pass functions as parameter and the function can hold different arguments? -
currently call function in way:
typedef struct optionvaluestruct{ const char *option_name; int (*func)(char*, char**); } optionvaluestruct_t; int parse2parameter(char *opt_name, char** opt_val); int parse3parameter(char *opt_name, char** opt_val, int a); const optionvaluestruct_t option_values[] = { {"counter1", parse2parameter} };
where parse2parameter func() having 2 parameters defined in optionvaluestruct_t.
how possible use
const optionvaluestruct_t option_values[] = { {"counter1", parse2parameter}, {"counter2", parse3parameter} };
where parse2parameter() , parse3parameter() has different number/type of parameters?
what trying do, , why?
think code receive function pointer. how going know how call it?
Comments
Post a Comment