编译过了 运行老说某处内存不能为read
#include <stdio.h>#include <stdlib.h>
typedef struct Lnode
{
int data;
struct Lnode *next;
}LinkList;
/***************************************************/
//函数申明
void InitList(LinkList *L);
void ListCreat(LinkList *L,int n);
//本地变量
LinkList *ListHead;
int main(int argc, char *argv[])
{
ListCreat(ListHead,8);
system("PAUSE");
return 0;
}
void ListCreat(LinkList *L,int n)
{
LinkList *p;
int i,j=0;
InitList(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;
}
}
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");
}