首页 新闻 会员 周边

关于c语言在读取二进制文件时的问题

0
[已关闭问题] 关闭于 2014-05-21 22:09

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Student_info
{
char name[10];
int id;
};

struct Student_info * from_file()
{
FILE *fp;
struct Student_info *p;
int loop = 0;

if( fp = fopen("stud1.dat","rb" ) == NULL)
{
printf( "not open\n" );
}
else
{
while( !feof(fp) )
{
loop++;
}
}

printf("%d",loop);

}

int main()
{
from_file();
return 0;
}

 

这段程序可以编译,但是运行时会报错,然后直接退出

一直不明白为什么,求大神解释下。

lleo小浩的主页 lleo小浩 | 初学一级 | 园豆:200
提问于:2014-05-21 22:01
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册