Is there a problem with creating linked lists in C language?

-sharpinclude<stdio.h>
-sharpinclude<stdlib.h>

typedef struct node{
    int num;
    struct node *next;
} Node;

int main(void)
{
    Node *link=NULL,*node;
    if(link=(Node *) malloc(sizeof(Node)))
    {
        link->num=-1;
        link->next=NULL;
        node=link->next;
    }
    int i=0;
    for(;i<10;iPP)
    {
        if(node=(Node *) malloc(sizeof(Node)))
        {
            node->num=i;
            node->next=NULL;
            node=node->next;
        }
    }
    for(node=link->next;node;node=node->next)
    {
        printf("%d  ",node->num);
    }
    putchar("\n");
    return 0;
}

running this code does not show any numbers. Why?

C
Mar.16,2021

link->next=NULL;
node=link->next;

after the execution of these two lines, you don't let link- > next point to node , just set node to empty. You should point link- > next to the first node of the linked list

after the for loop.
Menu