关于文件操作的问题:Run time error!
程序代码://从键盘输入5个学生的有关数据,然后把它们转存到其它磁盘文件上去。
#include"stdio.h"
#define N 5
struct student
{
int num;
char name[20];
float score;
}stu[5];
void main()
{
FILE *fp;
int i;
for(i=0;i<N;i++)
scanf("%d %s %f",&stu[i].num,stu[i].name,&stu[i].score);
if((fp=fopen("file1.dat","wb"))==NULL)
{
printf("can not open file!\n");
return;
}
for(i=0;i<N;i++)
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
printf("file write error!\n");
fclose(fp);
}
第一次运行还能把数据全部输入,后面360报告我这个程序是病毒,接着就运行不了。大家帮忙看看,是程序有问题还是系统中毒了。









