Question

I obtain a Segmentation Fault when i=0 and j=2; But I don't know why !

Could you help me ?

That's my function :

void allocationdynamiquetableautroisdimdentier(int**** Matrice,int nbniveau, int nbligne, int nbcolonne)
{
int i,j;
    *Matrice=(int***) malloc (sizeof(int**)*nbniveau);
    for (i=0; i<nbniveau; i++)
    {
        (*(Matrice))[i]=(int**) malloc (sizeof(int*)*nbligne);  // allocation dynamique de la matrice Matrice
        for (j=0; j<nbligne; i++)
        {
            ((*(Matrice))[i])[j]=(int*) malloc (sizeof(int)*nbcolonne);
        } 
    }

}
Was it helpful?

Solution

        for (j=0; j<nbligne; i++)

should be

        for (j=0; j<nbligne; j++)

OTHER TIPS

You have i++ in both loop statements!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top