#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *next;
}lnode,*linklist;
linklist creat_list ()
{
linklist head=null;
head= (linklist) malloc (sizeof (Lnode));
if (head==null)
{
printf ("Memory out of use\n");
return NULL;
}
head->next=null;
head->data=0;
return head;
}
int Insert (linklist head,int N)
{
for (int i=0;i<n;i++)
{
Linklist head_t=head->next;
Linklist New_node=null;
new_node= (linklist) malloc (sizeof (Lnode));
if (new_node==null)
{
printf ("Memory out of use\n");
return-1;
}
printf ("Please input the value:\n");
scanf ("%d", &new_node->data);
new_node->next=head_t;
head->next=new_node;
}
return 0;
}
int show_list (linklist head)
{
linklist tem;
tem=head->next;
While (TEM)
{
printf ("%3d", tem->data);
tem=tem->next;
}
return 0;
}
int main ()
{
linklist head;
int n;
printf ("Please input the size which your want to insert\n");
scanf ("%d", &n);
head=creat_list ();
Insert (head,n);
Show_list (head);
return 0;
}
Setting up single-linked list by head interpolation