主题:[讨论]大家帮忙看看这个有什么问题啊,总是运行不了
[em18][em18][em18]源代码如下:
#include<stdio.h>
#include<stdlib.h>
struct intnode{
long no;
char a[10];
float score;
struct intnode* next;
};
void main()
{
FILE*fp;
struct intnode*head,*tail,*p;
fp=fopen("E:\\aa.txt","r");
head=(struct intnode *)malloc(sizeof(struct intnode ));
head ->next=NULL;
head=tail;
while(!feof(fp))
{
p=(struct intnode *)malloc(sizeof(struct intnode ));
fscanf(fp,"%d",p->no);
fscanf(fp,"%s",p->a);
fscanf(fp,"%f",p->score);
p->next=NULL;
tail->next=p;
tail=p;
}
fclose(fp);
p=head->next;
printf("学号\t姓名\t成绩 \n");
while(p!=NULL)
{
printf("%d \t%s\t%f\n",p->no,p->a,p->score);
p=p->next;
}
}
[code=c]
请填写代码
[/code]
#include<stdio.h>
#include<stdlib.h>
struct intnode{
long no;
char a[10];
float score;
struct intnode* next;
};
void main()
{
FILE*fp;
struct intnode*head,*tail,*p;
fp=fopen("E:\\aa.txt","r");
head=(struct intnode *)malloc(sizeof(struct intnode ));
head ->next=NULL;
head=tail;
while(!feof(fp))
{
p=(struct intnode *)malloc(sizeof(struct intnode ));
fscanf(fp,"%d",p->no);
fscanf(fp,"%s",p->a);
fscanf(fp,"%f",p->score);
p->next=NULL;
tail->next=p;
tail=p;
}
fclose(fp);
p=head->next;
printf("学号\t姓名\t成绩 \n");
while(p!=NULL)
{
printf("%d \t%s\t%f\n",p->no,p->a,p->score);
p=p->next;
}
}
[code=c]
请填写代码
[/code]