链表为什么只输出最后一个节点

构建了一个有头结点的链表,输出的时候 只输出了头结点和最后一个节点的内容
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define wen "C:\Users\123\Desktop\WYT.txt"
typedef struct link {
struct link* before;
int cont;
int num;
struct link* next;
}Link;
void add1(Link* tail, int cont, int num);
int main() {
Link* head;
Link* tail;
head =(Link*) malloc(sizeof(Link));
tail = head;
int a, b;
scanf_s("%d %d", &a, &b);
while (a != -1) {
add1(tail, a, b);
scanf_s("%d %d", &a, &b);

}
while (head != NULL)
{
    printf("%d %d", head->cont, head->num);
    head = head->next;
}

}
void add1(Link* tail, int cont, int num) {
Link* p;
p = (Link*)malloc(sizeof(Link));
p->cont = cont;
p->num = num;
p->next = NULL;
tail->next = p;
tail = tail->next;
}

修改处见注释,供参考:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define wen "C:\\Users\\123\\Desktop\\WYT.txt"//修改
typedef struct link {
    struct link* before;
    int cont;
    int num;
    struct link* next;
}Link;
void add1(Link** tail, int cont, int num); //修改
int main()
{
    Link* head;
    Link* tail;
    head =(Link*) malloc(sizeof(Link));
    head->next = NULL;
    tail = head;
    int a, b;
    scanf("%d %d", &a, &b);
    while (a != -1) {
        add1(&tail, a, b); //修改
        scanf("%d %d", &a, &b);
    }
    while (head->next != NULL)  //(head != NULL)修改
    {
        printf("%d %d  ", head->next->cont, head->next->num); //修改
        head = head->next;
    }

    return 0;
}
void add1(Link** tail, int cont, int num)//修改
{
    Link* p;
    p = (Link*)malloc(sizeof(Link));
    p->cont = cont;
    p->num = num;
    p->next = NULL;
    (*tail)->next = p;//修改
    (*tail) = (*tail)->next;//修改
}

第一个while 构建链表 第二个while 输出链表 函数用来加一个新节点