I'm facing a problem with storing characters in the following code. It is compiled but it is not taking 2nd,4th,6th... characters as inputs.
struct ll {
char data;
struct ll *next;
};
Here is the code for creating a Linked list.
struct ll* create_ll(struct ll *start){
struct ll *p1,*p2;
char a;
printf("Enter q to stop\n");
printf("Enter data:");
scanf("%c",&a);
while(a != 'q'){
p1 = (struct ll*)malloc(sizeof(struct ll*));
p1 -> data = a;
if(start == NULL){
start = p1;
p2 = p1;
p1 -> next = NULL;
}
else{
p2 -> next = p1;
p1 -> next = NULL;
p2 = p1;
}
printf("Enter data:");
scanf("%c",&a);;
}
return start;
}