I'm using double linked list for keeping 4 different records in c.

I'm having trouble while creating space for doubly linked list. When I try to add more than 2 nodes, I lose all nodes except the first node and I'm seeing data of first and last nodes. I can't see the nodes from 2nd to last. I tried changing links between nodes but it didn't work. Here is my code;

```
struct node {
    char name[100];
    char surname[100];
    char roll[100];
    char department[100];
    struct node *next;
    struct node *prev;
};

struct node *first_oto = NULL, *last_oto = NULL, *l;

 void insert() {
     int i, counter = 1;

     first_oto = (struct node*)malloc(sizeof(struct node));
     first_oto->prev = NULL;
     first_oto->next = NULL;

     printf(" %d- Name:", counter);
     scanf("%s", first_oto->name);
     printf(" %d-Surname", counter);
     scanf("%s", first_oto->surname);
     printf(" %d-Number", counter);
     scanf("%s", first_oto->roll);
     printf(" %d-Department", counter);
     scanf("%s", first_oto->department);
     first_oto->next = NULL;

     for (i = 1; i < n; i++) {
         counter++;

         l = (struct node*)malloc(sizeof(struct node));

         printf(" %d-Name:", counter);
         scanf("%s", l->name);
         printf(" %d-Surname:", counter);
         scanf("%s", l->surname);
         printf(" %d-Number:", counter);
         scanf("%s", l->roll);
         printf(" %d-Department:", counter);
         scanf("%s", l->department);
         printf("\n");

         l->next = NULL;
         l->prev = first_oto;
         first_oto->next = l;
    }

```

In first part of the insert function my code is taking records of first nodes. While my program operates for loop it takes other nodes but adds only final node. What should I do to fix it?