/* reading from the binary file */
#include"stdio.h"
main()
{
FILE *fp;
struct emp
{
char name[40];
int age;
float bs;
};
struct emp e;
clrscr();
fp=fopen("emp.dat","rb");
if(fp==NULL)
{
puts("cannot open file");
exit();
}
while(fread(&e,sizeof(e),1,fp)==1)
printf("\n%s\n%d\n%f",e.name,e.age,e.bs);
fclose(fp);
getch();
}
#include"stdio.h"
main()
{
FILE *fp;
struct emp
{
char name[40];
int age;
float bs;
};
struct emp e;
clrscr();
fp=fopen("emp.dat","rb");
if(fp==NULL)
{
puts("cannot open file");
exit();
}
while(fread(&e,sizeof(e),1,fp)==1)
printf("\n%s\n%d\n%f",e.name,e.age,e.bs);
fclose(fp);
getch();
}
No comments:
Post a Comment