mercredi 16 septembre 2015

Segmentation fault (core dumped) when filling matrix with random numbers

What I'm trying to do is to simply fill 2 matrix with random numbers. However with the code I have I get a segmentation fault (core dumped) error and I have no idea why. I'd really appreciate the help.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int matA[3][3];
int matB[3][3];

int main() {

   srand(time(NULL));
   int i, j;

   for(i=0; i<3; i++)
   {
      for(j=0; j<3; i++)
      {
        matA[i][j] = (rand() % 9) + 1; 
        matB[i][j] = (rand() % 9) + 1;
      }     
   }

}




Aucun commentaire:

Enregistrer un commentaire