segmentation fault compiler error in C : <pre><code>Node* Insert(Node *head,int data)
{
 // Complete this method
   Node *temp, *temp1;
   temp1 = head;
   temp = (Node *)malloc(sizeof(Node));
   temp-&gt;data = data;
   temp-&gt;next = NULL;
   while(temp1-&gt;next!=NULL){
       temp1 = temp1-&gt;next;
   }
   temp1-&gt;next = temp;
   return head;
}
</code></pre>

<p>I am trying to write simple code to insert at the end of the array. The method works for GCC compiler, but gives segmentation fault error when compiling using an online compiler on HackerRank. Does the program work differently for different compilers.   </p>
