Linked list in c displayed with same values : <p>I have a CSV file containing lines separated by ','</p>

<p>The file looks like this:</p>

<pre><code>FIRST,00-92-93,1,0,1
SECOND,53-12-53,5,1,5
THIRD,12-33-51,5,0,51
</code></pre>

<p>Linked list looks like this:</p>

<pre><code>struct Data{
    char *dat;
    char *uname;
    bool war_dep;
    int edu_period;
    bool dorms;
};

struct llist{
    Data d;
    llist *next;
};
</code></pre>

<p>I have a function that itterates over this file, separating each line into chunks and 
adding them to a structure. </p>

<p>Here's my programm:</p>

<pre><code>void showi(llist *u){
    while(u){
        printf("Name: %s\t Date: %s\n", u-&gt;d.dat, u-&gt;d.uname);
        u=u-&gt;next;
    }
}

void inserti(llist **head, char *line){
    char *tok;
    llist *p=new llist;
    int i=0;

    tok = strtok(line, ",");
    while(tok!=NULL){
            switch(i){
            case 0:
                p-&gt;d.dat=tok;
                break;
            case 1:
                p-&gt;d.uname=tok;
                break;
            case 2:
                p-&gt;d.war_dep=atoi(tok);
                break;
            case 3:
                p-&gt;d.edu_period=atoi(tok);
                break;
            case 4:
                p-&gt;d.dorms=atoi(tok);
                break;
            }
            i++;
            tok=strtok(NULL, ",");
            }
    p-&gt;next=NULL;
    if(*head!=NULL)
        p-&gt;next=*head;
    *head=p;

    printf("Callback: %s\n", p-&gt;d.dat);
}

int main()
{
    FILE *fp;
    char line[128], *tok;
    llist *head;

    head = NULL;
    int i=0;
    fp=fopen("data.txt", "r");

    while(fgets(line, sizeof(line), fp))
    {
        inserti(&amp;head, line);
    }
    fclose(fp);

    showi(head);

    return 0;
}
</code></pre>

<p>When above code is executed I get callbacks from <strong>inserti</strong> (just to make sure each line is processed properly), however when I try to display my list I got only the last value (in this case I get 3 <strong>THIRD</strong>). I don't know why it happens, maybe something wrong with this piece of code in <strong>inserti</strong></p>

<pre><code>p-&gt;next=NULL;
    if(*head!=NULL)
        p-&gt;next=*head;
    *head=p;
</code></pre>
