#include <stdio.h>
#include <string.h>


struct people {
  char firstname [50];
  char surname [50];
  char address [100];
  int age;
};

void print_person(struct people person) {

  printf( "First name: %s\n", person.firstname);
  printf( "Surname: %s\n", person.surname);
  printf( "Address: %s\n", person.address);
  printf( "Age: %d\n", person.age);
} //end print_person ()


int main()
{
  struct people person1;
  FILE *fp;
  fp = fopen("personfile.dat","r");
  if (fp == NULL) {
    fprintf(stderr,"Problem opening file\n");
    exit(1);
  }

  while (!feof(fp)) {
    fread(&person1,sizeof(struct people),1,fp);
    print_person(person1);
  }
  fclose(fp);
}

