title: Linked list C char set last name added to everyone
body: <p>I wrote a program to be used as a line organizer, but when the time comes to show the a person's name, it sets the last person added to all others.  How can I fix it?
  If I change the info in <code>struct</code>, it bugs; however, if someone can help me, I'd be glad.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  struct node {
    int priority;
    int info;
    struct node *link;
  } *front = NULL;
  
  void insert(char person[20], int person_priority);
  int del();
  void display();
  int isEmpty();
  
  int main() //!! fixed
  {
    int choice, person_priority;
    char person[20];
  
    while (1) {
      printf("1.Insert Person\n");
      printf("2.Attend Client\n");
      printf("3.Show Queue\n");
      printf("4.Exit\n");
      printf("Type choice : ");
      scanf("%d", &amp;choice);
  
      switch (choice) {
      case 1:
        printf("Type persons name:");
        scanf("%s", &amp;person);
        printf("Its Priority:\n1 Pregnant\n2 Older\n3 Standard: ");
        scanf("%d", &amp;person_priority);
        insert(person, person_priority);
        system("cls");
        break;
      case 2:
        system("cls");
        printf("Person was attended", del());
        break;
      case 3:
        system("cls");
        display();
        break;
      case 4:
        exit(1);
      default:
        printf("Invalid Choice\n");
      }                           /*end of switch */
    }                             /*end of while */
    return 0;   //!! fixed
  }                               /*end of main() */
  
  
  void insert(char person[20], int person_priority)
  {
    struct node *tmp, *p;
  
    tmp = (struct node *) malloc(sizeof(struct node));
  
    if (tmp == NULL) {
      printf("No Memory available\n");
      return;
    }
  
    tmp-&gt;info = person;
    tmp-&gt;priority = person_priority;
  /*Starting list*/
    if (isEmpty() || person_priority &lt; front-&gt;priority) {
      tmp-&gt;link = front;
      front = tmp;
    }
    else {
      p = front;
      while (p-&gt;link != NULL &amp;&amp; p-&gt;link-&gt;priority &lt;= person_priority)
        p = p-&gt;link;
      tmp-&gt;link = p-&gt;link;
      p-&gt;link = tmp;
    }
  }                               /*end of insere() */
  
  int del()
  {
    struct node *tmp;
    int person;
  
    if (isEmpty()) {
      printf("Empty Queue\n");
      exit(1);
    }
    else {
      tmp = front;
      person = tmp-&gt;info;
      front = front-&gt;link;
      free(tmp);
    }
  
    return person;
  }                               /*end of del() */
  
  int isEmpty()
  {
    if (front == NULL)
      return 1;
    else
      return 0;
  }                               /*end of emtpy verification (isEmpty()) */
  
  void display()
  {
    struct node *ptr;
    ptr = front;
    if (isEmpty())
      printf("Empty Queu\n");
    else {
      printf("Line :\n");
      printf("Priority       Name\n");
      while (ptr != NULL) {
        printf("%5d        %5s\n", ptr-&gt;priority, ptr-&gt;info);
        ptr = ptr-&gt;link;
      }
      printf("\n\n\n");
    }
  }    
  </code></pre>