Hallo everyone! this is my first post so if I make any mistakes plase let me know..

I am writing this program in which I generate a hilbert matrix and create it's inverse. then I manipulate these 2 matrices and obtain other ones, that I shall call M,M1, M2, etc.. at a certain point I want to save one of these matrices, say M, on a file and to do so, I have to write and independet function that is called from the main.. this is what I wrote but it's not working!! can anyone help?!

/* function to save matrix on file */

Code:void savematrix(double n, double matrix[][MaxDim]) { int i,j; FIlE *f1; f1=fopen("matrix.txt","w"); if (f1=NULL) { printf("file could not be opened"); exit(-1); } for (i=0;i<n;i++) { for (j=0;j<n;j++) { fprintf(f1,"%5.2f ", matrix[i][j]); } fprintf(f1,"\n"); } fclose(f1); }