title: does a function automatically return dynamically allocated variable?
body: <p>While Studing the Tree Data Structure, I came across this code which traverse the tree in preorder</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  #include &lt;stdlib.h&gt; 
  
  struct node 
  { 
     int data; 
     struct node* left; 
     struct node* right; 
  };
  
  struct node* newNode(int data) 
  { 
      struct node* node = (struct node*)malloc(sizeof(struct node)); 
      node-&gt;data = data; 
      node-&gt;left = NULL; 
      node-&gt;right = NULL; 
      return node;
  }
  void printPreorder(struct node* node) 
  { 
      if (node == NULL) 
          return; 
      printf(&quot;%d &quot;, node-&gt;data);
      printPreorder(node-&gt;left); 
      printPreorder(node-&gt;right); 
  }    
  
  int main() 
  { 
      struct node *root = newNode(1); 
      root-&gt;left   = newNode(2); 
      root-&gt;right = newNode(3); 
      root-&gt;left-&gt;left = newNode(4); 
      root-&gt;left-&gt;right = newNode(5);  
      printf(&quot;\nPreorder traversal of binary tree is \n&quot;); 
      printPreorder(root); 
      getchar(); 
      return 0; 
    }
  </code></pre>
  <p>In the function newNode(int data), even if we remove the return statement the code works totally fine.
  So, my question is does the function newNode is automatically returning the node variable or something else is happening?</p>
  <p>Any help is Appreciated. Thanks!</p>