title: Triple pointers in C: is it a matter of style?
body: <p>I feel like triple pointers in C are looked at as "bad". For me, it makes sense to use them at times.</p>
  
  <p>Starting from the basics, the <strong>single pointer</strong> has two purposes: to create an array, and to allow a function to change its contents (pass by reference):</p>
  
  <pre><code>char *a;
  a = malloc...
  </code></pre>
  
  <p>or</p>
  
  <pre><code>void foo (char *c); //means I'm going to modify the parameter in foo.
  { *c = 'f'; }
  
  char a;
  foo(&amp;a);
  </code></pre>
  
  <p>The <strong>double pointer</strong> can be a 2D array (or array of arrays, since each "column" or "row" need not be the same length). I personally like to use it when I need to pass a 1D array:</p>
  
  <pre><code>void foo (char **c); //means I'm going to modify the elements of an array in foo.
  { (*c)[0] = 'f'; }
  
  char *a;
  a = malloc...
  foo(&amp;a);
  </code></pre>
  
  <p>To me, that helps describe what foo is doing. However, it is not necessary:</p>
  
  <pre><code>void foo (char *c); //am I modifying a char or just passing a char array?
  { c[0] = 'f'; }
  
  char *a;
  a = malloc...
  foo(a);
  </code></pre>
  
  <p>will also work.</p>
  
  <p>According to the first answer to <a href="https://stackoverflow.com/questions/1106957/passing-an-array-by-reference-in-c">this question</a>, if <code>foo</code> were to modify the size of the array, a double pointer would be required.</p>
  
  <p>One can clearly see how a <strong>triple pointer</strong> (and beyond, really) would be required. In my case if I were passing an array of pointers (or array of arrays), I would use it. Evidently it would be required if you are passing into a function that is changing the size of the multi-dimensional array. Certainly an array of arrays of arrays is not too common, but the other cases are.</p>
  
  <p>So what are some of the conventions out there? Is this really just a question of style/readability combined with the fact that many people have a hard time wrapping their heads around pointers?</p>