So I'm doing an assignment where we need to pass functions we've made ourselves into a library provided for us.
Tree * createBinTree(int (*comparePointer) (TreeDataTypePtr data1,
TreeDataTypePtr data2), void (*destroyPointer) (TreeDataTypePtr));
Is the code I've been provided. My function pointer for the comparePointer is
int(*compStr)(void *, void *) = &compareName;
Compare is
int compareName(void * rest1, void * rest2);
But when I pass it through like so
Tree * myTree = createBinTree((compstr)(str1,str2),die(str1));
I only get an error on compstr which is "passing argument 1 of createBinTree makes pointer from integer without a cast" and "expected 'int (*)(void *, void *) but argument is of type int.
Tree * myTree = createBinTree(compstr, die);- Eugene Sh.