J
jova
I've posted this in the learn c-c++ group as well. Can some please help me
with why the rooot pointer variable keeps changing. First it is what is
supposed to be then it just changes. Here are some excerpts of my code.
I made root a global variable pointer.
struct binaryNode *root;
The first thing I did was set it NULL in the main.
root = NULL;
Then I use a integer and my root as a arguments in my insert method to
create the a Tree.
void insert(int x, struct binaryNode *node)
{
if(root==NULL)
{
root = node;
root -> value = x;
}
.......
}//end of insert I've cut the function just like you see here and the root
still changes
This is how I call the insert method
.......
struct binaryNode tempNode = createNode();
insert(number, &tempNode);
.......
And here his the createNode function.
struct binaryNode createNode()
{
struct binaryNode *t;
t = (malloc(sizeof(struct binaryNode)));
return *t;
}
Any Help is appreciated.
with why the rooot pointer variable keeps changing. First it is what is
supposed to be then it just changes. Here are some excerpts of my code.
I made root a global variable pointer.
struct binaryNode *root;
The first thing I did was set it NULL in the main.
root = NULL;
Then I use a integer and my root as a arguments in my insert method to
create the a Tree.
void insert(int x, struct binaryNode *node)
{
if(root==NULL)
{
root = node;
root -> value = x;
}
.......
}//end of insert I've cut the function just like you see here and the root
still changes
This is how I call the insert method
.......
struct binaryNode tempNode = createNode();
insert(number, &tempNode);
.......
And here his the createNode function.
struct binaryNode createNode()
{
struct binaryNode *t;
t = (malloc(sizeof(struct binaryNode)));
return *t;
}
Any Help is appreciated.