title: Insertion in Circular Linked List (output not coming as desired)
body: <p>This is the method I wrote in C. It is for insertion in a linked list.   </p>
  
  <pre><code>void insert_beg()
  {
  temp=(struct node*)malloc(sizeof(struct node));
  ptr=(struct node*)malloc(sizeof(struct node));
  
  int data_value;
  
  printf("Enter the value\n");
  scanf("%d",&amp;data_value);
  
  temp-&gt;info=data_value;
  
  if(header-&gt;link==NULL)//when there is no node
  {
      header-&gt;link=temp;
      temp-&gt;link=header;
  }
  else//when atleast one node has been created
  {
      ptr-&gt;link=header-&gt;link;//ptr is pointing to where header was pointing.
      header-&gt;link=temp;
      temp-&gt;link=header;
  }
  
  printf("\n\n");
  }
  </code></pre>
  
  <p>This is the code for traversal (basically display)</p>
  
  <pre><code> void traverse()
  {
  ptr=header-&gt;link;
  
  while(ptr-&gt;link!=header)
  {
      ptr=ptr-&gt;link;
      printf("%d\t",ptr-&gt;info);
  }
  printf("\n\n");
  }
  </code></pre>
  
  <p>When running the program, the output for traversal is nothing. It's as if the for loop is not running. There is no segmentation fault when inserting or any other thing.
  Is my logic correct? If not, then where am I going wrong?</p>