title: Calling insert function in c from a header file
body: <p>My professor send me a library to insert,delete and search elements in a linked list:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  
  struct NODE
  {
      char AM[12];
      char name[40];
      int semester;
      struct NODE *head;
      struct NODE *next;
      struct NODE *prev;
  };
  
  void init(struct NODE **head)
  {
      *head=NULL;
  }
  
  struct NODE *Search (struct NODE *head,char CODE[],struct NODE **prev)
  {
      struct NODE *tmp;
      *prev=NULL;
      tmp=head;
      while (tmp!=NULL &amp;&amp; tmp-&gt;AM&lt;CODE)
      {
          *prev=tmp;
          tmp=tmp-&gt;next;
      }
      if (tmp==NULL)
      return NULL;
      if (tmp-&gt;AM==CODE)
      return tmp;
      return NULL;
  }
  
  struct NODE *Search2 (struct NODE *head,char name[],struct NODE **prev)
  {
      struct NODE *tmp;
      *prev=NULL;
      tmp=head;
      while (tmp!=NULL &amp;&amp; tmp-&gt;name&lt;name)
      {
          *prev=tmp;
          tmp=tmp-&gt;next;
      }
      if (tmp==NULL)
      return NULL;
      if (tmp-&gt;name==name)
      return tmp;
      return NULL;
  }
  
  int Insert (struct NODE **H,struct NODE P)
  {
      struct NODE *cur,*prev;
      cur=Search(*H,P.AM,&amp;prev);
      if (cur)
      return 0;
      cur=(struct NODE *)malloc(sizeof P);
      *cur=P;
      if (prev==NULL)
      {
          cur-&gt;next=*H;
          *H=cur;
      }
      else
      {
          cur -&gt; next = prev -&gt; next;
          prev -&gt; next = cur;
      }
      return 1;
  }
  
  int Delete (struct NODE **H,char AM[])
  {
      struct NODE *cur,*prev,*next;
      cur=Search(*H,AM,&amp;prev);
      if (!cur)
      return 0;
      if (prev==NULL)
      cur=next;
      else
      prev-&gt;next=cur-&gt;next;
      free(cur);
      return 1;
  }
  
  void traverse (struct NODE *head)
  {
      struct NODE *cur;
      cur=head;
      while (cur)
      {
          printf ("%p\n",cur);
          cur=cur-&gt;next;
      }
  }
  </code></pre>
  
  <p>Now here is a piece of code from the source file that i created in an attempt to insert an element in the linked list:</p>
  
  <pre><code>case 1:printf ("Input AM,name and semester of student: "); 
  tmp=(struct NODE *)malloc(sizeof(struct NODE)); 
  if (tmp==NULL) 
  exit(1); 
  scanf("%s %s %d",tmp-&gt;AM,tmp-&gt;name,&amp;tmp-&gt;semester); 
  _flag=Insert(&amp;head,*tmp); 
  if(_flag) 
  printf ("Student inserted succesfully!\n"); 
  free(tmp);
  break;
  </code></pre>
  
  <p>When i insert the element i get the "Student inserted succesfully" message,but when i call the search function to find that element,it returns NULL (meaning that the element is not in the list).How should i call the Insert function from the header file? (I assume the problem must be in the Insert function).Also in main() i have declared the following two:</p>
  
  <pre><code>struct NODE *head;
  struct NODE *tmp;
  </code></pre>
  
  <p>Should i change something regarding those two?</p>