title: New approach for adding a new Node to a Linked List
body: <pre><code>void addNewNode (struct node *head, int n)
  {
      struct node* temp = (struct node*) malloc(sizeof(struct node));
      temp -&gt; data = n;
      temp -&gt; link = head;
      head = temp;
  }
  </code></pre>
  
  <p>The code give above is the popularly wrong version of a function for adding a new node at the head of a linked list.
  Generally the correct versions are like,</p>
  
  <pre><code>void addNewNode (struct node **head, int n);
  void addNewNode (struct node * &amp;head, int n);
  </code></pre>
  
  <p>I worked out another but simple function for the purpose which worked fine.</p>
  
  <pre><code>struct node* addNewNode (struct node *head, int n)
  {
      struct node* temp = (struct node*) malloc(sizeof(struct node));
      temp -&gt; data = n;
      temp -&gt; link = head;
      return temp;
  }
  </code></pre>
  
  <p>But I haven't seen this being used or discussed in code and tutorials and thus I am curious to know if this approach has some flaw.</p>