title: Head Pointer is changing with linked list items
body: <p>This program is supposed to print new element and the start element. But the start element is getting changed every time I assign a new element. <code>init_class()</code> returns a pointer to class.</p>
  
  <pre><code>/*
    Class-&gt;Albert
              |
              V
           Einstein
  
  */
  
  
  #include "datadef.h"
  int main(int argc, char* argv[])
  {
      char Name[30][30];
  
      if (argc != 2)
      {
          printf("Incorrect number of arguments, please retry...\n");
          exit(0);
      }
  
      Class* classp;
      classp = init_class();
  
      FILE* fp;
      fp = fopen(argv[1],"r");
  
      if (fp == NULL)
      {
          printf("File pointer allocation error...Ending the program..\n");
          exit(0);
      }
      int count = 0;
      Student* prevp;
      Student* currp;
      while(!feof(fp))
     {
          fscanf(fp,"%s",Name[count]);
          currp = init(Name[count]);
          if (!count)
          {
              classp-&gt;startp = currp;
              printf("Assigned the head pointer\n");
          }
          else
          {
              prevp-&gt;nextp = currp;
              printf("appending to the pre-existing list\n");
          }
          count+=1;
          prevp = currp;
          printf("Current : %s \n",currp-&gt;name);
          printf("Head : %s \n",classp-&gt;startp-&gt;name);
          printf("\n\n");
      }
  </code></pre>
  
  <p>Result:</p>
  
  <blockquote>
    <p>Assigned the head pointer</p>
    
    <p>Current : Albert </p>
    
    <p>Head : Albert </p>
    
    <p>appending to the pre-existing list</p>
    
    <p>Current : Einstein </p>
    
    <p>Head : Einstein </p>
  </blockquote>
  
  <p>Expected result:</p>
  
  <blockquote>
    <p>Assigned the head pointer</p>
    
    <p>Current : Albert </p>
    
    <p>Head : Albert </p>
    
    <p>appending to the pre-existing list</p>
    
    <p>Current : Einstein </p>
    
    <p>Head : Albert</p>
  </blockquote>
  
  <p>Here's init()</p>
  
  <pre><code>/*init()*/
  Student* init(char* name)
  {
      Student* currentp = (Student*)malloc(sizeof(Student));
      if (!currentp)
      {
          printf("pointer allocation problem..Ending the program...\n");
          exit(0);
      }
      currentp-&gt;name = name;
      currentp-&gt;nextp = NULL;
      currentp-&gt;scoreHeadp = NULL;
  
     return currentp;
  </code></pre>
  
  <p>}</p>