I need to figure out how to pass two different structs to a function. I tried using void * for the parameter but i am receiving the error:
warning: dereferencing 'void *' pointer
error: request for member left in something not a structure or union
same error for member right
here is what i did in general terms(code may not compile).
struct A{
char *a;
struct A *left, *right;
} *rootA;
struct B{
char *b;
struct B *left, *right;
} *rootB;
void BinaryTree(void *root, void *s){
if(condition)
root->left=s;
else if(condition)
BinaryTree(root->left, s);
if(condition)
root->right=s;
else if(condition)
BinaryTree(root->right, s);
}
int main(){
// Assume the struct of nodeA and nodeB get malloc()
// as well as the variables a and b with actual data.
struct A nodeA;
struct B nodeB;
BinaryTree(rootA, nodeA);
BinaryTree(rootB, nodeB);
return 0
}