|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#define UNLL 0
#define STR struct stu
struct stu
{
int xh;
char name[20];
STR *next;
};
STR *lb();
main()
{
STR *head;
head=lb();
for(;head;)
{
printf("%d %s\n",head->name,head->xh);
}
}
STR *lb()
{
STR *head,*p1,*p2;
head=p1=UNLL;
for(;;)
{
p1=(STR *)malloc(sizeof(STR));
p1->next=UNLL;
printf("输入节点信息:\n");
scanf("%d",&p1->xh);
if(!(p1->xh))
break;
scanf("%s",&p1->name);
if(head==p1)
head=p2=p1;
else
{
p2->next=p1; //执行到这就不执行了>_<! Run-Time Check Failure #3 - The variable 'p2' is beingused without being initialized.
p2=p1;
}
}
p2->next=UNLL;
return head;
}
|
|