Let's say I have a function which takes these parameters.
int create(Ptr * p,void * (*insert)(void *, void *)) {
//return something later
}
And the struct:
typedef struct {
void ** ptr;
void * (*insert)(void *, void *));
}Ptr;
Where p is a pointer to a struct, and insert is a function pointer to a function with two general pointers (void pointers), to insert a integer in a given tree (I'm using void pointers because in this case it's a integer, in other cases it may not be).
How would I go about calling the function create, here?
I know I can do something along the lines of this for the first parameter:
//in a seperate .c file
Ptr * pt;
pt = malloc(sizeof(Ptr));
create(pt,....what to put here)?
If I wanted to pass the struct pointer as an argument, and an integer to be inserted second (Again they're both void pointers because it is a generic build).
insertfunction, and shouldn't pass it as an argument to thecreatefunction (as i suppose you don't need to have a separateinsertfunction for every node in the tree). - CristiFati