title: Array of pointers to a struct with pointers in that struct
body: <p>The part that is bothering me is the last <code>for</code> loop which I used just to test whether the data is entered correctly and that it is printed using <code>printf</code> properly. The three access methods used to print the data which I entered aren't quite clear to me.</p>
  
  <p>In <strong>access method #1</strong> I managed to print data properly using only one arrow operator to access name. The part I can't wrap my head around is why am I able to access the data without an error? I only used index to access each <code>production_plant_employees</code> structure. I know the brackets do the dereferencing, but I still don't understand what's happening there. I tried writing that part like this : <code>*(production_plant_employees + i)</code>, but it didn't work.</p>
  
  <p><strong>Access method #2</strong> is fully clear to me.</p>
  
  <p>Now the <strong>access method #3</strong>, that's the one I assumed would work, but it refuses to. When written, IDE shows no errors, but when I run the program, it stops.</p>
  
  <p>I am supposed to first access data in first pointer (which is <code>production_plant_employees</code>), and then then access data in second pointer (which is pointer <code>basic_info</code> which is in struct <code>employee</code>), and then, when I've gone through the 2 pointers, access the very data I am after (name, age, etc...), right?</p>
  
  <p>Also, could you please show me any other possible ways of accessing the data I'm after?</p>
  
  <pre><code>typedef struct basicdata{
      char name[15];
      char last_name[15];
      char gender[2];
      int age;
      char birthplace[15];
      char address[15];
  } BASICDATA;
  
  typedef struct job_info {
      int employment_year;
      char job_position[20];
      char employee_pay_grade[10];
      int employee_grade;
  } JOB_INFO;
  
  typedef struct employee{
      BASICDATA *basic_info;
      JOB_INFO *job_info;
  } EMPLOYEE;
  
  
  int main () {
  
      int i;
      int choice = 0;
  
      EMPLOYEE *production_plant_employees;
  
      printf("Enter number of employees : \n");
      scanf("%d", &amp;choice);
  
      production_plant_employees = (EMPLOYEE*)calloc(choice, sizeof(EMPLOYEE));
      if (production_plant_employees == NULL) {
          printf("An error occured during memory allocation\n");
      }
  
      for(i = 0; i &lt; choice; ++i) {
          production_plant_employees[i].basic_info = (BASICDATA*)calloc(choice, sizeof(BASICDATA));
          if(production_plant_employees[i].basic_info == NULL) {
              printf("An error occured during memory allocation\n");
          }
  
          production_plant_employees[i].job_info = (JOB_INFO*)calloc(choice, sizeof(JOB_INFO));
          if(production_plant_employees[i].job_info == NULL) {
              printf("An error occured during memory allocation\n");
          }
  
          printf("production_plant_employees[%d].basic_info = %d\t%x\n", i, production_plant_employees[i].basic_info, production_plant_employees[i].basic_info);
          printf("production_plant_employees[%d].job_info = %d\t%x\n", i, production_plant_employees[i].job_info, production_plant_employees[i].job_info);
      }
  
      for(i = 0; i &lt; choice; ++i) {
          fflush(stdin);
          printf("Enter name : \n");
          fgets(production_plant_employees[i].basic_info-&gt;name, 15, stdin);
  
          printf("Name of %d. employee : %s", i, production_plant_employees[i].basic_info-&gt;name) //access method#1
          printf("Name of %d. employee : %s", i, (production_plant_employees + i)-&gt;basic_info-&gt;name);  //access method #2
          printf("Name of %d. employee : %s", i, *(*(production_plant_employees +i)).basic_info-&gt;name); //access method #3 ---&gt; why isn't this working?
          printf("\n\n");
      }
      return 0;
  }
  </code></pre>