#include <stdio.h>
struct toys{ char name[20]; int cost;} toy;

int main()
{ FILE *f;
 f=fopen("test2.dat","r+b");
 puts("File of toys");
 printf("  Toy name    cost\n");
 puts("__________________");
 while(fread(&toy,sizeof(toy),1,f)>0)
  printf(" %8s   %5d\n",
                          toy.name,toy.cost);
 fclose(f);
 return 0;
}
