链表死循环了 帮忙救下
#include<iostream.h>#include"malloc.h"
struct node
{
int data;
struct node *next;
};
struct node *next,*null,*p,*L,*s,*q;
int j,e,n,k;
void create( )
{
L=(struct node *)malloc(sizeof(struct node));
L->next=null;
s=L;
while(k!=-1)
{
cin>>k;
p=(struct node *)malloc(sizeof(struct node));
p->data=k;
s->next=p;
s=p;
}
p->next=null;
}
void showL()
{
cout<<"您所建立的链表如下:"<<endl;
while(p!=null)
{
p=L->next;
cout<<p->data<<" ";
p=p->next;
}
}
int main()
{
create();
showL();
return 0;
}
谢谢!!!帮下忙啊~~~