title: How do i print out Characters from a single linked list?
body: <p>When the user inputs a single character into the link list the program should print out the list but I am having a problem when a character is inputted it wont print out the characters and causes a infinite loop but works perfect when a number is inputted. Any ideas? </p>
  
  <pre><code>        #include &lt;stdio.h&gt;  
          #include "stdafx.h"
          #include &lt;stdlib.h&gt;
          #include &lt;malloc.h&gt;
  
          /*Structure containing a Data part &amp; a Link part to the next node in the List  */
  
          struct Node  
          {  
              int Data;  
              struct Node *Next;  
          }*Head;  
  
  
  
          int count()  
          {  
          /* Counting number of elements in the List*/
            struct Node *cur_ptr;  
            int count=0;  
  
            cur_ptr=Head;  
  
            while(cur_ptr != NULL)  
            {  
               cur_ptr=cur_ptr-&gt;Next;  
               count++;  
            }  
            return(count);  
          }  
  
  
          void addEnd(char input)  
           {  
              struct Node *temp1, *temp2;  
  
              temp1=(struct Node *)malloc(sizeof(struct Node));  
              temp1-&gt;Data=input;  
  
              // Copying the Head location into another node.  
              temp2=Head;  
  
              if(Head == NULL)  
              {  
                 // If List is empty we create First Node.  
                 Head=temp1;  
                 Head-&gt;Next=NULL;  
              }  
              else  
              {  
                 // Traverse down to end of the list.  
                 while(temp2-&gt;Next != NULL)  
                 temp2=temp2-&gt;Next;  
  
                 // Append at the end of the list.  
                 temp1-&gt;Next=NULL;  
                 temp2-&gt;Next=temp1;  
              }  
           }    
  
          // Displaying list contents  
  
          void display()  
          {  
            struct Node *cur_ptr;  
  
            cur_ptr=Head;  
  
            if(cur_ptr==NULL)  
            {  
               printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
               printf("\nList is Empty "); 
               printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\n\n");
            }  
            else  
            {  
                printf("\nElements in the List:\n\n ");  
                //traverse the entire linked list  
                while(cur_ptr!=NULL)  
                {  
                    printf(" \n-&gt; %d ",cur_ptr-&gt;Data);  
                    cur_ptr=cur_ptr-&gt;Next;  
                }  
                printf("\n");
              }
          }
  
          int main(int argc, char *argv[])  
          {  
           int i=0;  
  
           //Set HEAD as NULL  
           Head=NULL;  
  
           while(1)  
           {  
  
              printf("\n\n\n\n\n MENU\n");  
              printf("---------------------------------\n");  
              printf(" \n1. Insert one part of DNA sequence");   
              printf(" \n2. Print the Elements in the List");   
              printf(" \n\n3. Exit\n");  
              printf(" \nChoose Option: ");  
              scanf("%d",&amp;i);  
  
              switch(i)  
              {  
                case 1:  
                {  
                    char dnaChar;  
                    printf(" \nEnter char to be inserted into the List i.e A, T, G, C: ");  
                    scanf("%d",&amp;dnaChar);  
                    addEnd(dnaChar);  
                    display();  
                    break;  
                }     
  
                case 2:  
                {  
                    display();  
                    break;  
                }  
  
  
                case 3:  
                {  
                    struct Node *temp;  
  
                    while(Head!=NULL)  
                    {  
                        temp = Head-&gt;Next;  
                        free(Head);  
                        Head=temp;  
                    }  
                    exit(0); 
                  }  
  
                default:  
                {  
                    printf("\nWrong Option \n\n\n\n");  
                }  
              } 
           } 
          }  
  </code></pre>