#include <stdio.h>
#include <stdlib.h>

typedef struct { 
    int id; 
    char pname[20]; 
    char psurname[20]; 
    double salary;
} Person; 

void ReadData() {
	FILE *fp = fopen ("citizens.dat", "rb"); 
    if (fp == NULL)  { 
        printf("\nError opening file citizens.dat\n"); 
        exit (1); 
    } 
	fseek(fp, 0, SEEK_END);
	long int fsize = ftell(fp);
	printf("File size = %ld\n", fsize);
	
	fseek(fp, 2 * sizeof(Person), SEEK_SET);

	Person temp;
	
    if(fread( &temp, sizeof(Person), 1, fp) == 1) {
       printf ("id = %d name = %s \t surname = %s \tsalary = %lf\n", 
	      temp.id, temp.pname, temp.psurname, temp.salary); 
   }
   
   rewind(fp);

    if(fread( &temp, sizeof(Person), 1, fp) == 1) {
       printf ("id = %d name = %s \t surname = %s \tsalary = %lf\n", 
	      temp.id, temp.pname, temp.psurname, temp.salary); 
   }

   
   fclose(fp);
}

int main(int argc, char *argv[]) {
	ReadData();
	return 0;
}

