Enter name, age and salary: Rajiv 41 82000.00
More records (y/n)? y
Enter name, age and salary: Mayur 31 55000.00
More records (y/n)? n
Solution 4(c):
#include
#include
void main( )
{
struct
{
char name[30];
int age;
float sal;
} emp;
FILE * fp;
clrscr( );
if ((fp = fopen(“test.dat”, “rb”)) = =NULL)
{
printf(“\n Cannot open file”);
exit(1);
}
while (fread (&emp, sizeof (emp), 1, fp) = = 1)
printf(“\n %s\t%d\t%f”, emp.name, emp.age, emp.sal);
fclose (fp);
getch( );
}
Do'stlaringiz bilan baham: