title: Using pointer inside a struct
body: <p>Suppose I have the following:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  typedef struct
  {
      int num;
  } myObj;
  
  typedef struct
  {
      myObj *obj_ptr;
  } myStruct;
  
  void populate(myStruct *m1)
  {
      m1-&gt;obj_ptr-&gt;num = 123;
  }
  
  int main()
  {
      printf("Hello World");
      myStruct m1;
      populate(&amp;m1);
  
      printf("%d", m1.obj_ptr-&gt;num);
  
      return 0;
  }
  </code></pre>
  
  <p>The purpose of this code is I want to get an item e.g. <code>m1</code> populated instead of being returned by the <code>populate</code> function, hence the way it is coded.</p>
  
  <p>I'm concerned about the line <code>m1.obj_ptr-&gt;num</code> since it doesn't seem like a good design. Are there any issues with this code even as I got it to run? Is there a better approach to this?</p>