void generate_sequence (int xs, int currentlen, int seqlen, int *seq);
void check_loop_iterative(void (*f)(?), int xs, int seqlen, int *loop, int *looplen);
I need to pass first function to second function.So my question is.How should I fill the parameters where the question mark is?
CodePudding user response:
This is how you deal with function pointers in a manner that will keep you sane:
Write a
typedef
similar to the function declaration you want. In this case it's just about addingtypedef
in front and coming up with a meaningful type name:typedef void sequence_t (int xs, int currentlen, int seqlen, int *seq);
It doesn't matter what you name the parameters to and you don't even need to name them, though you should ideally have all functions of this type using the same parameter names. So regard the
typedef
as a function template.To use a function pointer to this function type, simply do
sequence_t* ptr;
.
CodePudding user response:
You write the same list as the pointed function has.