title: Bus error 10 with 2d array of struct inside struct
body: <p>I'm having issues filling a 2d array of a struct inside a struct. It allows me to do it for pixels[0][1], pixels[0][2]....etc. However, once I increase the first index i.e pixels[1][1], I get a bus error 10. Any help would be appreciated. I've cut out some code to make it more readable but if you require all of it let me know! What the program is doing is reading a PPM image and displaying the information, the trouble i'm having is storing the pixels of the image.</p>
  
  <pre><code>#define MAX_HEIGHT 4
  #define MAX_WIDTH 4
  
  typedef struct Pixel{
  
    int red;
    int green;
    int blue;
  
  }Pixel;
  
  typedef struct PPM{
  
    char code[2];
    int width, height;
    int max;
    Pixel * pixels[MAX_HEIGHT][MAX_WIDTH];
  
  
  }PPM;
  
  struct PPM * getPPM(FILE * fd){
  
     PPM * image = NULL;
  
     image = malloc(sizeof(PPM));
  
     //have got all the other PPM info here ask if needed
  
  
     int i;
     int j;
  
  
     for(i = 0; i&lt;MAX_HEIGHT-1; i++){
       for(j = 0; j&lt;MAX_WIDTH-1; j++){
         //  struct Pixel newPPM_Pixel;
         if(fscanf(fd, "%d %d %d", &amp;image-&gt;pixels[i][j]-&gt;red, &amp;image-&gt;pixels[i][j]-&gt;green, &amp;image-&gt;pixels[i][j]-&gt;blue) == 3){
         //rgb_array[i][j] = newPPM_Pixel;
         printf("/ %d / %d  / %d", image-&gt;pixels[i][j]-&gt;red, image-&gt;pixels[i][j]-&gt;green, image-&gt;pixels[i][j]-&gt;blue);
        }
      }
    }
  
   return image;
  }
  </code></pre>