I have to use a 3 dimensions array because I want to divide a pic into squares and store the average of the RGB of each square in my array.
I want it to be this size, tab[height][width][3],
so I did that:
i = 0; j = 0; k = 0;
    float*** tab;
    tab = malloc((hauteur+1)*sizeof(float*));
    while(i <= hauteur){
        tab[i] = malloc((largeur+1)*sizeof(float**) );
        i++;
    }
    i = 0;
    while(i <= hauteur){
        j = 0;
        while (j <= largeur){
            tab[i][j] = malloc(3*sizeof(float***));
            j++;
        }
        i++;
    }
but I have a segfault after : tab[1][30][2];.
Is there a problem in my malloc?
It's strange because it doesn't segfault when I declare tab using:
tab[hauteur][largeur][3].
(Sorry: "hauteur" means "height" in French and "largeur" means "width".)
(If you think you need to check my whole function: http://pastebin.com/eqQXz8Ad; it's a writer for a JPEG file.)
 
     
     
     
     
    