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;
}

ok i've solved the issue by just making it add nodes at the end of the list instead,
and it worked fine that way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.