请问那里错了,输出的文本和我输入的数据不不同
#include <conio.h>
#include "stdio.h"
#define NULL 0
#define LEN sizeof(struct stuinfo)
struct stuinfo /*学生信息结构体*/
{ char num;
int score;
struct stuinfo *next;
};
typedef struct stuinfo STU;
STU *creat(int n)
{ int i;
STU *head,*p1,*p2;
for(i=0;i<n;i++)
{p1=(STU *)malloc(LEN);
if(p1==NULL)printf("ERROR");
printf("Input the student number and score like this \"**-**\":");
scanf("%d-%d",&p1->num,&p1->score);
if(i==0)
p2=head=p1;
else
p2->next=p1;
p1->next=NULL;
p2=p1;
}
return(head);
}
main()
{int n;
STU *head;
STU *creat(int n);
void save(STU *p);
printf("Input amount of the student:");
scanf("%d",&n);
head=creat(n);
save(head);
}
void save(STU *p)
{
FILE *fp;
fp=fopen("e:\\date.txt","w");
do
{fprintf(fp,"The number of the stendent is %d\n",&p->num);
fprintf(fp,"The score of the %d is: %d\n\n",&p->num,&p->score);
p=p->next;
}
while(p->next!=0);
}
[此贴子已经被作者于2007-3-4 22:48:18编辑过]