When I execute the below code the for loop takes the input less number of times. I even used getchar() but the issue still did not resolve. Please provide the correct code for it
int main(void)
{
struct node *head = NULL;
int n;
char c;
int k;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%c %d", &c,&k);
if (c == 'a')
{
head = add(k, head);
}
else if (c == 'd')
{
head = del(k, head);
}``
}
printstruct(head);
return 0;
}