title: dereferencing struct pointer to structure variable
body: <p>I am having a little bit of confusion about derefrencing a structure pointer to a 
  structure variable.</p>
  
  <p>It will be good if I demonstrate my problem with an example.</p>
  
  <p>So here I am:</p>
  
  <pre><code>struct my_struct{
      int num1;
      int num2;
  }tmp_struct;
  
  void Display_struct(void * dest_var){
  
      struct my_struct struct_ptr;
  
      struct_ptr = *((struct my_struct *)dest_var);
  
      printf("%d\t%d\n",struct_ptr.num1,struct_ptr.num2);
  
  }
  
  int main()
  {
      tmp_struct.num1 = 100;
      tmp_struct.num2 = 150;
  
  
      Display_struct(&amp;tmp_struct);
      return 0;
  }
  </code></pre>
  
  <p>Now when I am running this example I am able to get the code to be compiled in a very clean manner and also the output is correct.</p>
  
  <p>But what I am not able to get is that is this a correct way of dereferencing the structure pointer to a structure variable as we do in case of other simple 
  data types like this:</p>
  
  <pre><code>int example_num;
  
  void Display_struct(void * dest_var){
  
      int example_num_ptr;
  
      example_num_ptr = *((int *)dest_var);
  
      printf("%d\t%d\n",struct_ptr.num1,struct_ptr.num2);
  }
  
  int main()
  {
      example_num = 100;
  
  
      Display_struct(&amp;example_num);
      return 0;
  }
  </code></pre>
  
  <p>Here we can dereference the int pointer to int variable as it is a simple data
  type but in my opinion we can't just dereference the structure pointer in similar manner to a structure variable as it is not simple data type but a complex data type or data structure.</p>
  
  <p>Please help me in resolving the concept behind this.</p>