c语言关于文件的问题,查了资料自己也解决不了
学校的课设是写一个文本编辑系统,遇到了一个文件的问题:
程序代码:List daoru(FILE *fp) {
char str[1001];
List p, head = NULL, tail = NULL;
while (!feof(fp)) {
p = (List)malloc(sizeof(struct node));
fgets(p->str, 1000, fp);
if (head == NULL)head = p;
else {
tail->next = p;
}
tail = p;
}
if (head)tail->next = NULL;
return head;
}这是一个从文件中把每一行导入到链表中的函数,但循环只能进入一次.求解



