I'm doing a project and need the user to input a series of chars to fill a matrix. This is the code I've written:
#include <stdio.h>
#include <string.h>
int main(void) {
  int i, j;
  getchar(); 
  scanf(" %i %i", &i, &j);
  
  char matrix[i][j];
  
  for (int a = 0; a < i; a++) {
      char temp[j];
      memset(temp, 0, j);
      getchar();
      fgets(temp, j, stdin);
      scanf("%c", temp);
      
      for (int b = 0; b < j; b++) {
        matrix[a][b] = temp[b];
      }
  }
return 0;
}
The error displayed was: signal: segmentation fault (core dumped), and I'm not sure how to fix it
 
    