title: what is the EOF of binary file?
body: <p>My program needs to read from a binary file to a linked list, this function doing it well and allocating the right memory for it but for some reason it doing another loop before it breaks. tried looking for a good solution for it with no luck, and the last struct in the linked list getting junk.</p>
  
  <p>The struct:</p>
  
  <pre><code>typedef struct
  {
      char id[10];
      char * first_name;
      char * last_name;
      int age;
      char gender;
      char * username;
      char * password;
      char * description;
      int hobbies[4];
      struct Person * next_client;
  }Person;
  </code></pre>
  
  <p>here is some code:</p>
  
  <pre><code>Person * input_from_file(Person * member)
  {
  int str_size;
  Person * clients_start = NULL;
  FILE * filePointerRead;
  
  filePointerRead = fopen("input.bin", "rb");
  
  if (filePointerRead != NULL){
      while (1){
  
          member = NULL;
          member = (Person*)malloc(sizeof(Person));
  
          fread(&amp;member-&gt;id, sizeof(char), ID_DIGITS + 1, filePointerRead);
  
          fread(&amp;str_size, sizeof(int), 1, filePointerRead);
          member-&gt;first_name = (char*)malloc(str_size*sizeof(char));
          fread(member-&gt;first_name, sizeof(char), str_size, filePointerRead);
  
          //more reading from file
  
          member-&gt;next_client = NULL;
          clients_start = receive_clients_info(clients_start, member);  //function to put the received struct from file to end of the linked list
  
          if (feof(filePointerRead))
              break;
      }
      fclose(filePointerRead);
  }
  return clients_start;
  }
  </code></pre>