I have to create a binary tree using the struct as follows:
struct treenode;
typedef struct treenode* TreeNode;
struct treenode {
void* data;
TreeNode left, right;
};
using void* as the type for the data to be stored at each leaf, so that an object of any type can be inserted into the tree.
When I am inserting a new leaf, I have to use a compare function, which checks if data in the new leaf is already in the tree, that takes two void* parameters eg:
int compare(void* a, void* b){
..
..
}
but how can I compare the two objects if I don't know what type they are?
Some code to solve this problem would be really helpful.