Now there is the need to create a binary tree root node pointer in the main function, in the Tree_create function, malloc or new binary tree node, and then in the main function can be normal access to the new node.
Note: The return value of tree_create here is void, which means that a pointer to a node cannot be returned by the return value of the function.
The way to think about this is to pull back the data from the node by a level two pointer. The specific implementation process is this:
void Tree_create (tree **tmp); int main (void) {Tree *t = null;//t is a pointer to a two-fork tree node//The address of T is passed to Tree_create function tmp// The value passed is placed in the corresponding memory unit of TMP tree_create (&t);}
Here's a bad way to analyze how their memory is stored:
void Tree_create (tree *tmp); int main (void) {Tree *t = null;//t is a pointer to a two-fork tree node//the contents of T, that is, the data in the memory unit corresponding to t//This data is either the memory address of a node, Either the null//passes this value to the Tmptree_create (T) of the Tree_create function;}
First look at the way the memory is arranged in the wrong way:
Then look at the correct way of arranging the memory:
In the way of memory display, this paper analyzes the working mode of the two-level pointer pull-back data. It also shows the wrong way.
C pointer--pull back data with a level two pointer