title: C Double Pointer to Structure
body: <p>I am trying to work out a double pointer to a structure in C and cannot figure out what is going wrong... The simple source is below:</p>
  
  <pre><code>typedef struct
  {
      int member;
  } mystruct;
  
  void myfunc(mystruct **data)
  {
      (*data)-&gt;member = 1;
  }
  
  void main(int argc, char *argv[])
  {
      mystruct **data;
  
      myfunc(data);
  
      printf("member = %d\n", (*data)-&gt;member);
  }
  </code></pre>
  
  <p>A similar question was asked here: <a href="https://stackoverflow.com/questions/346730/how-to-work-with-pointer-to-pointer-to-structure-in-c">How to work with pointer to pointer to structure in C?</a> on how to modify a member of a structure through a double pointer. The solution was the syntax <code>(*data)-&gt;member = 1;</code> which makes sense. But in my little application here, I receive a seg fault when executing that line. What am I doing wrong? </p>
  
  <p>Thanks</p>