求帮忙看下这个程序有什么错误
#include <stdio.h>#include <malloc.h>
struct node
{
char name;
int num,score;
struct node *next;
};
struct node *create()
{
printf("请输入学生的信息,以输入学号为0结束\n");
printf("\t学号\t姓名\t分数\n");
struct node *Head,*p,*tail;
int date;
Head = (struct node *)malloc(sizeof(struct node));
Head->next = NULL;
tail = Head;
p = (struct node *)malloc(sizeof(struct node));
p->next = NULL;
while(scanf("%d",&date) != EOF)
{
if(date == 0) break;
p->num = date;
scanf("%s %d",p->name,&p->score);
tail->next = p;
tail = p;
p = (struct node *)malloc(sizeof(struct node));
p->next = NULL;
}
system ("pause");
return Head;
}
void print(struct node *Head)
{
printf("\t\t学生信息输出\n");
printf("\t学号\t姓名\t分数\n");
struct node *p;
p = Head->next;
while(p != NULL)
{
printf("\t%d\t%s\t%d\n",p->num,p->name,p->score);
p = p->next;
}
}
int main()
{
struct node *head;
head = create();
print(head);
system ("pause");
return 0;
}
是有点奇怪,但是可以运行。
system(...) 要 #include <stdlib.h>
scanf 之前请 printf 提示
页:
[1]