title: Deleting first node without head pointer in C
body: <p>I am trying to make linked list code that makes deletion from first node.I created a struct a</p>
  <pre><code>struct node{
    int data;
    struct node *next;
  };
  </code></pre>
  <p>Then added some nodes, without using head pointer, here is my main</p>
  <pre><code>int main(){
  struct node *first = malloc(sizeof(struct node));
  struct node *second = malloc(sizeof(struct node));
  struct node *third = malloc(sizeof(struct node));
  struct node *forth = malloc(sizeof(struct node));
  
  first-&gt;data = 1; //assing data in first node
  first -&gt; next = second; // link first node with second node
  
  second -&gt; data = 2;
  second -&gt; next = third;
  
  third -&gt; data = 3;
  third -&gt; next = forth;
  
  forth -&gt; data = 4;
  forth-&gt;next = NULL;
  
  printList(first);
  
  // deletefromBeg(first);
  
      //printList(first);
  
  }
  </code></pre>
  <p>Here my printList code for printing the list</p>
  <pre><code>void printList(struct node *n){
  while (n != NULL){
      printf(&quot;%d\n&quot;,n-&gt;data);
      n = n -&gt; next;
  }
  }
  </code></pre>
  <p>But this deletion code doesn't work. I just want to delete my first node and list starts second.</p>
  <pre><code>void deletefromBeg(struct node *first){
  struct node *temp;
  temp = first;
  first = first-&gt;next;
  printf(&quot;%d&quot;,temp-&gt;data);
  free(temp);
  }
  </code></pre>