#include <stdio.h>
#include <stdlib.h>
typedef struct Lnode {
int data;
struct Lnode *next;
} LinkList;
/***************************************************/
//函数申明
void InitList(LinkList **L);//KEY
void ListCreat(LinkList *L, int n);
void ShowList(LinkList *L);
//本地变量
LinkList *ListHead = NULL;
int main(int argc, char *argv[]) {
ListCreat(ListHead, 8);
system("PAUSE");
return 0;
}
void ListCreat(LinkList *L, int n) {
LinkList *p;
LinkList *head;
int i, j = 0;
InitList(&L);
head = L;
printf("Begin to input data!!\n");
printf("you gonna creat an list which have %d int data\n", n);
for (i = n; i > 0; --i) {
p = (LinkList *) malloc(sizeof(LinkList));
p->data = i;
p->next = L->next;
L->next = p;
}
ShowList(L);
}
void InitList(LinkList **L) {
printf("Initialization Begin!\n");
printf("sizeof(Lnode)=%d\n", sizeof(LinkList));
*L = (LinkList *) malloc(sizeof(LinkList));
//**L ->next = NULL;
printf("Initialization End!\n");
}
void ShowList(LinkList *L)
{
LinkList *p;
p =L ->next;
while(p != NULL)
{
fprintf(stderr,"number = %d\n",p->data);
p =p ->next;
}
}