C语言调试错误

来源:百度知道 编辑:UC知道 时间:2024/05/14 05:30:39
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define LEN sizeof(linklist)
typedef struct node
{
int data;
struct node *next;
}linklist;
linklist *head;
linklist *creat()
{
linklist *head;
linklist *p;
linklist *rear;
head=(struct node*)malloc(LEN);
head->data=20;
rear=head;
int i;
for(i=0;i<20;i++)
{
p=(struct node*)malloc(LEN);
p->data=(rand())%100;
rear->next=p;
rear=p;
printf("\n\t");
printf("%d",p->data);

}
rear->next=NULL;
printf("\n链表创建成功!");
return(head);
}
int length(linklist *head)
{
linklist *p;
int length=0;
p=head;
while(p->next!

#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define LEN sizeof(linklist)
typedef struct node
{
int data;
struct node *next;
}linklist;
linklist *head;
linklist *creat()
{
// linklist *head;//这句屏蔽掉,就可以了!
linklist *p;
linklist *rear;
int i;
head=(struct node*)malloc(LEN);
head->data=20;
rear=head;

for(i=0;i<20;i++)
{
p=(struct node*)malloc(LEN);
p->data=(rand())%100;
rear->next=p;
rear=p;
printf("\n\t");
printf("%d",p->data);

}
rear->next=NULL;
printf("\n链表创建成功!");
return(head);
}
int length(linklist