I'm looking over some old code and I am having trouble getting to the print statement after the scanf function. Everytime I run this code I have to break it using control c. What am I missing about Linked Lists that could help me solve this issue? For context I haven't taken a class in C in ages and I would like to review how to properly use data structures like Linked Lists but for some reason this problem I did ages ago is eluding me. What should I do?
#include <stdio.h>
#include <stdlib.h>
void trav_and_print(void);
typedef struct linked_list
{
   int data;
   struct linked_list *next;
}   element;
int a;
int* pA = &a;
typedef element * elementptr;
  elementptr first = NULL,
            last = NULL,
            current;
            
int main()
{
   /* Create a linked list with one element            */
   /* NOTE: the first element is always a special case */
   
   first = (elementptr) malloc(sizeof(element));
   last = first;
   last -> data = 5;
   last -> next = NULL;
   /* Add another element to the end of the list */
   last -> next = (elementptr) malloc(sizeof(element));
   last = last -> next;
   last -> data = 12;
   last -> next = NULL;
   printf("%d \n",last->data);
   last -> next = (elementptr) malloc(sizeof(element));
   last = last -> next;
   printf("Enter a number: ");
   scanf("%d\n",pA);
   fflush(stdin); 
   last -> next = (elementptr) malloc(sizeof(element));
   last = last -> next;
   last -> data = a;
   last -> next = NULL;
   printf("Number added is %d \n",last -> data);
   trav_and_print();
   free(first);
   free(last);
   return 0;
}
void trav_and_print(void)
{
   current = first;
   while (current!=NULL)
   {
      printf("The data value is %d\n",current -> data);
      current = current -> next;
   }
}
 
    