郑佳声爸爸 发表于 2018-2-27 20:43:05

我按照小甲鱼视频打的 为什么还是错误的呢

#include <stdio.h>
#include <stdlib.h>
void load();

int main()
{
    int i;
    load();
    for(i=0; i<4;i++)
    {
      printf("%10s%5d   %5d%10s",stu.name,stu.num,stu.age,stu.addr);
    }
}

void load()
{
    FILE *fp;
    int i;

    if(!(fp = fopen("student-list1","r")))
    {
      printf("cannot open the file;\n");
      return;
    }

    for(i=0 i<4;i++)
    {
      fread(&stu,sizeof(struct student),1,fp);
    }
    fclose(fp);
}

BngThea 发表于 2018-2-28 09:00:12

我怎么看你的fopen打开的文件没有后缀名呢

muwuren 发表于 2018-3-6 21:37:48

看上去像是少了个student全局变量结构体
页: [1]
查看完整版本: 我按照小甲鱼视频打的 为什么还是错误的呢