怎么将文件中的信息放入单链表中并显示出来
想弄个简单的学生成绩管理系统 发现弄不出
代码如下:
程序代码:#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#define FORMAT " | %-10s |%-15s|%4d|%4d|%4d| %4d | %.2f |%4d |\n"
#define DATA p->data.num,p->data.name,p->data.egrade,p->data.mgrade,p->data.cgrade,p->data.total,p->data.ave,p->data.mingci
typedef struct student /*标记为student*/
{
char num[10]; /*学号*/
char name[15]; /*姓名*/
int cgrade; /*C语言成绩*/
int mgrade; /*数学成绩*/
int egrade; /*英语成绩*/
int total; /*总分*/
float ave; /*平均分*/
int mingci; /*名次*/
};
typedef struct node
{
struct student data;
struct node *next;
}Node,*Link;
int main(int argc,char *argv[])
{
Link l; //链表
FILE *fp;
Node *p,*r;
l=(Node*)malloc(sizeof(Node));
l->next=NULL;
r=l;
fp=fopen("C:\\STUDENT","ab+"); //追加读写二进制文件
if(fp==NULL)
{
printf("\n=====>can not open file");
exit(0);
while(!feof(fp))
{
p=(Node*)malloc(sizeof(Node));
if(fread(p,sizeof(Node),1,fp)==1)
{
}
}
fclose(fp);
}
}






