#include <stdio.h>
struct node
{
int ID_no;
struct node* next;
}
struct node* mknode(int ID_no)
{
struct node* np;
np = (struct node*)malloc(sizeof(struct node));
if (np)
{
np->ID_no=ID_no;
np->next=NULL;
}
return np;
}
struct node* append_node(struct node** head, struct node* np)
{
struct node* n;
if(*head==NULL)
*head=np;
else
{
for (n=*head; n->next!=NULL; n=n->next);
n->next=np;
}
return np;
}
void display_list(struct node* head)
{
struct node* n;
for (n=head; n!=NULL; n=n->next)
printf("Dato numero= %d\n", n->ID_no);
}
int main(void)
{
int i;
struct node*n;
struct node* head=NULL;
for(i=0; i<10; i++)
{
n=mknode(i);
append_node(&head, n);
}
display_list(head);
return 0;
}