B
Bill Cunningham
I have this much down for a tree but still don't know what to do with
main. I have this struct.
struct node
{
double price;
int vol;
struct node *right;
struct node *left;
};
Now in the following node is an object of type struct and so is this but
node is also a function.
struct node *new(int v, double p)
{
struct node *this;
this = malloc(sizeof this);
if (!this)
return NULL;
this->vol = v;
this->price = p;
this->right = NULL;
this->left = NULL;
return this;
}
I'm 25% of the way there. I read this->price=p as the object this
pointing to the double price and p is assigning price. The objects right and
left are pointeres to the this object and also set to NULL.
That's making a new node. Now how to set the data to right and left I
don't know and how to delete nodes I don't know. I have only got this far.
Can someone help me out and I know there are tutorials on the web and they
look nice but they don't talk or explain.
Bill
main. I have this struct.
struct node
{
double price;
int vol;
struct node *right;
struct node *left;
};
Now in the following node is an object of type struct and so is this but
node is also a function.
struct node *new(int v, double p)
{
struct node *this;
this = malloc(sizeof this);
if (!this)
return NULL;
this->vol = v;
this->price = p;
this->right = NULL;
this->left = NULL;
return this;
}
I'm 25% of the way there. I read this->price=p as the object this
pointing to the double price and p is assigning price. The objects right and
left are pointeres to the this object and also set to NULL.
That's making a new node. Now how to set the data to right and left I
don't know and how to delete nodes I don't know. I have only got this far.
Can someone help me out and I know there are tutorials on the web and they
look nice but they don't talk or explain.
Bill