title: How to move the linked list from the last list to the front list in C?
body: <p>Basically this is all my coding for the project:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define TRUE 1
  #define FALSE 0
  
  void newThesis();
  void listThesis();
  void moveThesis();
  
  struct thesis
  {
      int thesis;
      char stud_name[30];
      char stud_id[10];
      char thesis_title[40];
      int thesis_year;
      struct thesis *ptrnext;
  };
  
  struct thesis *headptr, *newptr, *currentptr, *previousptr;
  
  int main()
  {
      char ch;
      int choice=TRUE;
      headptr=(struct thesis *)NULL;
      while(choice==TRUE)
      {
          printf("\n\nE - Enter thesis information");
          printf("\nL - List all thesis");
          printf("\nM - Move last node to first node");
          printf("\nX - Exit\n");
          printf("\nEnter choice: ");
          scanf(" %c",&amp;ch);
          switch(ch)
      {
          case 'E':newThesis();break;
          case 'L':listThesis();break;
          case 'M':moveThesis();break;
          case 'X':choice=FALSE; break;
          default: printf("\nEnter only one from the above");
      }
  }
  return 0;
  }
  
  void newThesis()
  {
      newptr=(struct thesis *)malloc(sizeof (struct thesis));
      if (headptr== NULL)
      {
          headptr=newptr;
          newptr-&gt;ptrnext= NULL;
      }
      else
      {
          newptr-&gt;ptrnext=headptr;
          headptr=newptr;
      }
      printf("\nTHESIS CODE:");
      printf("\n1 - Online Information Management System");
      printf("\n2 - Cursor Movement Using Finger Gesture");
      printf("\n3 - Tomato Maturity Estimator ");
  
      printf("\n\nEnter thesis code: ");
      scanf("%d",&amp;newptr-&gt;thesis);
      printf("\nEnter student name: ");
      scanf("%s",&amp;newptr-&gt;stud_name);
      printf("\nEnter student id: ");
      scanf("%s",&amp;newptr-&gt;stud_id);
      printf("\nEnter thesis title: ");
      scanf("%s",&amp;newptr-&gt;thesis_title);
      fflush(stdin);
      printf("\nEnter thesis year: ");
      scanf("%d",&amp;newptr-&gt;thesis_year);
      fflush(stdin);
  
      listThesis();
  }
  
  void listThesis()
  {
      if (headptr==NULL)
      {
          printf("\nEmpty list");
          return;
      }
      currentptr=headptr;
      do
      {
          printf("\n\n%d",currentptr-&gt;thesis);
          printf("\n%s",currentptr-&gt;stud_name);
          printf("\n%s",currentptr-&gt;stud_id);
          printf("\n%s",currentptr-&gt;thesis_title);
          printf("\n%d",currentptr-&gt;thesis_year);
          printf("\n");
          currentptr=currentptr-&gt;ptrnext;
      }
      while(currentptr != NULL);
  }
  </code></pre>
  
  <p>I'm having a problem on how to move the last list that have been inserted to the front list.</p>
  
  <p>I've tried many solutions from the internet and it didn't work. And the new function for it should be</p>
  
  <pre><code>void moveThesis();
  </code></pre>
  
  <p>*EDITED: I've got the answer and it works just great!!</p>
  
  <pre><code>void moveThesis()
  {
      currentptr = headptr;
      do
      {
      previousptr=currentptr;
      currentptr=currentptr-&gt;ptrnext;
      }while(currentptr-&gt;ptrnext !=NULL);
  
      currentptr-&gt;ptrnext=headptr;
      headptr=currentptr;
      previousptr-&gt;ptrnext=NULL;
  
      listThesis();
  }
  </code></pre>
  
  <p>Thanks for helping me guys!</p>