hi
what i wanna do is to insert an element in a binary search tree. this element is a structure with a field called key (which is a pointer to char). this shall be everytime the same. but i wanna be able to "atach" a body which can be anything i'd like to (int, struct, char ....). so i thought defining it like this would do the job:
Code:
struct streenode {
char *key;
void *body;
struct streenode *nextl,*nextr;
};
then i defined another structure for a body:
Code:
struct optionflagbody {
int status;
};
now i wrote this code sequence:
Code:
struct options readcfg(char *cfgfile)
{
struct optionflagbody *body;
struct options optns;
struct streenode keyword, *optionflags;
[...]
body = (struct optionflagbody *)malloc(sizeof(struct optionflagbody));
(*body).status = ON;
keyword.key = "Test";
keyword.body = body;
printf("%d",keyword.body->status);
optionflags = stinsert(optionflags,keyword);
[...]
}
printf("%d",keyword.body->status);
in the bold section the compiler aborts with the message: left operand of -> has incompatible type void
operand of = have illegal types pointer to void and void
any idea?
stormbringer