title: Three Dimensional array of structs in C
body: <p>Hello I am struggling to find a solution Ive defined the following 3D array of structures.</p>
  
  <pre><code>typedef struct{
    float x;
    float y;
    float z;
  } Point;
  
  Point ***Qw;
  
  Qw =  malloc(num_bezier * sizeof(Point **));
  for(i=0; i&lt;num_bezier; i++){
      Qw[i] =  malloc((m+1) * sizeof(Point *));
  
      for(j=0; j&lt;=m;j++)
        Qw[i][j] = malloc((p+1) * sizeof(Point));
    }
  </code></pre>
  
  <p>I can loop through the array to print its contents but at some point of the program after modifying some of the elements, Im no longer able to access some of the structs in the array and i get a segfault. Any help appreciated, thanks.</p>
  
  <p>PD: Ive just noticed i had defined incorrectly my struct...</p>
  
  <pre><code>typedef struct{
   double x;
   double y;
   float z;
  } Point;
  </code></pre>
  
  <p>As soon as i exchanged the double for float type it fixed the segfault... still trying to figure out why it was segfaulting</p>