why when i print the list it always misses the 1st line of input ?
here's my code:
#include<stdlib.h>
#include<stdio.h>
struct list {
char data;
struct list * next;
};
typedef struct list item;
int main()
{
item * curr, * head;
char c;
head = NULL;
while((c=getchar())!=EOF)
{
curr = (item *)malloc(sizeof(item));
curr->data = c;
curr->next = head;
head = curr;
}
curr = head;
while(curr)
{
printf("%c", curr->data);
curr = curr->next;
}
return 0;
}