单链表删除函数出现了问题,高手看看
#include "stdlib.h"#include "string.h"
#include "stdio.h"
#define NULL 0
typedef struct lode
{int data;
struct lode *next;
}lode,*linklist;
createlode(linklist p,int n)
{ int i;
linklist p1;
p1=p;
for(i=0;i<n;i++)
{insertlode(p1,i);
}
}
insertlode(linklist p,int n)
{ linklist s;
int j=0;
while(j<n)
{p=p->next;
j++;
}
s=(linklist)malloc(sizeof(struct lode));
scanf("%d",&s->data);
s->next=p->next;
p->next=s;
}
dellode(linklist p,int n)//问题函数。
{int j;
linklist s;
linklist pp=p->next;
while(pp->data!=n)
{pp=pp->next;
}
s=pp;
s=s->next;
free(pp);
}
showlode(linklist p)
{linklist pp=p->next;
printf("the circular linked list is:\n");
while(pp!=p)
{ printf("%d ",pp->data);
pp=pp->next;
}
printf("\n");
}
main()
{linklist p;
int n;
p=(linklist)malloc(sizeof(struct lode));
p->next=p;
printf("input the number of the circular linked list :");
scanf("%d",&n);
createlode(p,n);
showlode(p);
printf("input the number of what you want to del lode:\n");
scanf("%d",&n);
dellode(p,n);
showlode(p);
getch();
}