I've a structure that contains two pointers and a value. It is for a binary tree.
struct node
{
int value; //holds value of node
node *lesschild; //pointer to lesser value child
node *greatchild; //pointer to greater value child
};
And this structure is pointed to by a pointer in a function called addelement
and now I want to malloc
another structure that is pointed to by one of the pointers in the original node or structure, I'm occurring syntax problems and I am looking for help.
This is what I've for creating another structure that is pointed to by lesschild
which is in a structure that is pointed to by ptr
.
I'm then trying to change value in the new structure through the double pointer.
ptr->lesschild = &malloc(sizeof(struct node));
ptr->lesschild->value = add;
Can anyone tell me what I'm missing? Thanks for you help