C语言 !!!stream!=NULL 10
如题本想输出已经录入好了的数据结果出现提示stream!=NULL求解#include<stdio.h>#defineSIZE4structstudent{charnam...
如题 本想输出已经录入好了的数据 结果出现提示 stream!=NULL 求解
#include <stdio.h>
#define SIZE 4
struct student
{char name[10];
int num;
int age;
char addr[15];
}stud[SIZE];
void main()
{
int i;
FILE *fp;
fp=fopen("stu_list","rb");
for(i=0;i<SIZE;i++)
{
fread(&stud[i],sizeof(struct student),1,fp);
printf("%-10s%4d%4d%-15s\n",stud[i].name,&stud[i].num,&stud[i].age,stud[i].addr);
}
fclose(fp);
} 展开
#include <stdio.h>
#define SIZE 4
struct student
{char name[10];
int num;
int age;
char addr[15];
}stud[SIZE];
void main()
{
int i;
FILE *fp;
fp=fopen("stu_list","rb");
for(i=0;i<SIZE;i++)
{
fread(&stud[i],sizeof(struct student),1,fp);
printf("%-10s%4d%4d%-15s\n",stud[i].name,&stud[i].num,&stud[i].age,stud[i].addr);
}
fclose(fp);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询