What is wrong with the use of malloc?
I am reading a matrix from a file and have the following code:

 
    int  **mat;
    
    int main(void)
    {
     FILE *fp;
     if ((fp = fopen("matrix.txt", "r"))==NULL){
      printf("Cannot open file \n");
      exit(1);
      getch();
     }
 
     fscanf(fp, "%d", &N);//size of matrix NxN
 
     mat = (int**)malloc(N*sizeof(int*)); 

     for(i=1;i<=N;i++){
        mat[i] = (int*)malloc(N*sizeof(int));
      for(j=1;j<=N;j++)
    		fscanf(fp, "%1d", &mat[i][j]);
     }
 
     fclose(fp);

Could you please tell me what is wrong with the above code? Thank you
What is wrong with the use of malloc?
===

I am reading a matrix from a file and have the following code:

 
    int  **mat;
    
    int main(void)
    {
     FILE *fp;
     if ((fp = fopen("matrix.txt", "r"))==NULL){
      printf("Cannot open file \n");
      exit(1);
      getch();
     }
 
     fscanf(fp, "%d", &N);//size of matrix NxN
 
     mat = (int**)malloc(N*sizeof(int*)); 

     for(i=1;i<=N;i++){
        mat[i] = (int*)malloc(N*sizeof(int));
      for(j=1;j<=N;j++)
    		fscanf(fp, "%1d", &mat[i][j]);
     }
 
     fclose(fp);

Could you please tell me what is wrong with the above code? Thank you