Learn the C language. If you do not know the linked list or do not know where the linked list should be, it means that your C language has not learned well. Learn the linked list and know where the application is located, it means that you have mastered the basic things of C language.
/************************ Linkcreare. c *********************/
# Include "linkapi. H"
# Include <stdio. h>
# Include <stdlib. h>
Int main ()
{
Stud * P;
P = createnode (6 );
Displaynode (P );
Getchar ();
Return 0;
}
/************************** Linkapi. c ***********************/
# Include "linkapi. H"
Stud * createnode (int n)
{
Int I;
Stud * head, * P1, * P2;
Head = p1 = P2 = NULL;
For (I = 0; I <n; I ++)
{
P1 = (stud *) malloc (sizeof (stud ));
P1-> num = I;
If (I = 0)
{
Head = p1;
}
Else
{
P2-> next = p1;
}
P2 = p1;
}
P2-> next = NULL;
Return head;
}
Void displaynode (stud * P)
{
While (P! = NULL)
{
Printf ("the % d node num is % d \ n", p-> num, p-> num );
P = p-> next;
}
};
Void delnode (stud * P)
{
};
Void findnode (INT num)
{
};
/************************** Linkapi. h ***********************/
# Ifndef linkapi_h
# Define linkapi_h
# Include "malloc. H"
# Include "stdio. H"
# Include "stdlib. H"
Typedef struct node {
Int num;
Struct node * next;
} Stud;
Stud * createnode (int n );
Void displaynode (stud * P );
Void delnode (stud * P );
Void findnode (INT num );
# Endif
/******************* Makefile ******************* **********/
# This is a link for simple without circle
Cflags =-g-wall
Cc = gcc
Objects = linkcreate. O linkapi. o
Link: $ {objects}
$ {CC }$ {cflags}-o link $ {objects}
Linkapi. O: linkapi. c
$ {CC }$ {cflags}-C linkapi. c
Linkcreate. O: linkcreate. c
$ {CC }$ {cflags}-C linkcreate. c
Clean:
Rm-RF *. o link