0

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);
        } 
    }

}
ecatmur
  • 152,476
  • 27
  • 293
  • 366
giovedy
  • 123
  • 2
  • 4
  • 10

2 Answers2

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

should be

        for (j=0; j<nbligne; j++)
ecatmur
  • 152,476
  • 27
  • 293
  • 366
2

You have i++ in both loop statements!

ams
  • 24,923
  • 4
  • 54
  • 75