Pointer Initialization : When to assign NULL to the initialized pointer?
<pre><code>typedef struct nodetype 
{
 int data;
 struct nodetype * left;
 struct nodetype * right;
}node;

typedef node * tree;

tree newNode(int data)
{
 tree temp;
 temp = NULL;
 temp = (tree)malloc(sizeof(nodetype));
 temp-&gt;data = data;
 temp-&gt;right = NULL;
 temp-&gt;left = NULL;
 return temp;
}
</code></pre>

<p>Here in the function newNode, to create a node we assign NULL value to the "temp". I dont understand whether this is necessary. What will be the implications if we dont initialize it with NULL and in which cases should I take care of assigning a ptr to NULL while initializing it ??</p>
