求大神指教文件打开建表问题
#include <stdio.h>
#include "./ASC/simpio.h"
#include "struct.h"
#include "genlib.h"
#include "string.h"
#include "strlib.h"
NODE *readfromfile()
{
FILE *fp;
NODE *head = NULL,*p1,*p2;
int n = 0;
fp = fopen("student.txt","r");
if(fp == NULL)
{
printf("Can't open the file student.txt\n");
getchar();
exit(0);
}
p1 = (NODE *)malloc(sizeof(NODE));
p2 = (NODE *)malloc(sizeof(NODE));
fscanf(fp,"%s %s %d\n",p1->name,p1->number,p1->score);
while(!feof(fp))
{
n = n + 1;
if(n == 1)
head = p1;
else
p2->next = p1;
p2 = p1;
p1 = (NODE *)malloc(sizeof(NODE));
fscanf(fp,"%s %s %d\n",p1->name,p1->number,p1->score);
}
p2->next = NULL;
fclose(fp);
printf("Successful loading!\n");
return(head);
}