In my code, I am just trying to print initialized matrix using the function Print_Matrix(M), but when the function I am getting a segmentation fault, but when I print it within the main function it prints as expected
Here is my code to replicate the issue
#include<stdio.h>
#include<stdlib.h>
int N = 5;
typedef struct matrix{
    double m[1024][1024];
    int size;
}matrix;
matrix I;
void
Print_Matrix(matrix M)
{
    printf("hello\n");
    int row=0, col=0;
    for (row = 0; row < N; row++) {
        for (col = 0; col < N; col++){
            printf(" %5.2f", M.m[row][col]);
        }
        printf("\n");
    }
    printf("\n\n");
}
int main()
{
    int row, col;
    for (row = 0; row < N; row++) {
        for (col = 0; col < N; col++) {
            if (row == col)
                I.m[row][col] = 1.0;
        }
    }
    for(row=0;row<N;row++){
        for(col=0;col<N;col++){
            printf("%5.2f ", I.m[row][col]);
        }
        printf("\n");
    }
    Print_Matrix(I);
    return 0;
    
}
Output:
 1.00  0.00  0.00  0.00  0.00 
 0.00  1.00  0.00  0.00  0.00 
 0.00  0.00  1.00  0.00  0.00 
 0.00  0.00  0.00  1.00  0.00 
 0.00  0.00  0.00  0.00  1.00 
Segmentation fault (core dumped)
 
    