链表程序调试问题!比较急!~

来源:百度知道 编辑:UC知道 时间:2024/05/23 15:04:33
运行环境vc6.0
自己运行一下就会明白我的问题了,我不知道哪里错了,大家帮帮我!
#include <stdio.h>
#include <malloc.h>
#define LEN sizeof(struct student)
#define NULL 0
struct student
{
int num;
int score;
struct student *next;
};
struct student *creat(void)
{
struct student *p1,*p2,*head;
int i=0;
p1=p2=(struct student *)malloc(LEN);
scanf("%d,%d",&p1->num,&p2->num);
while(p1->num!=0)
{
i++;
if(i==1)
{
head=p1;
}
else
{
p2->next=p1;
}
p2=p1;
p1=(struct student *)malloc(LEN);
printf("--------------------------------------\n");
scanf("%d,%d",&p1->num,&p2->num);
}
p2->next=NULL;
return head;

}
void output(struct student *head)
{
struct student *p;
p=head;
whi

#include <stdio.h>
#include <malloc.h>
#define LEN sizeof(struct student)
#define NULL 0
struct student
{
int num;
int score;
struct student *next;
};
struct student *creat(void)
{
struct student *p1,*p2,*head;
int i=0;
p1=p2=(struct student *)malloc(LEN);
scanf("%d,%d",&p1->num,&p1->score);
while(p1->num!=0)
{
i++;
if(i==1)
{
head=p1;
}
else
{
p2->next=p1;
}
p2=p1;
p1=(struct student *)malloc(LEN);
printf("--------------------------------------\n");
scanf("%d,%d",&p1->num,&p1->score);
}
p2->next=NULL;
return head;

}
void output(struct student *head)
{
struct student *p;
p=head;
while(p!=NULL)
{
printf("\n--------------------------------------\n");