I am trying to perfrom multiplication on matrices entered in a text file. First line in text file should be the size (matrices are going to be use size for row and column size). The remaining lines will list the values in matrices. For example, in data.txt I might have:

2

1.2 2.3

-3.0 1.0

7.1 0.4

6.3 2.6

My multiplying doesn't work however, that's what I need help fixing. Here's the code.

Code:`#include <stdio.h>`

typedef struct {

int n;

double *entry; }

matrix;

FILE *file;

char filename[]="";

int n,i,j,k;

matrix *a;

matrix *b;

matrix *c;

int main (void) {

printf("Please enter the input file: ");

scanf("%s", &filename);

file = fopen(filename, "r");

if (file != NULL) {

}

else

{

printf("Error: File Not Found");

}

fscanf(file,"%d", &n);

a=(matrix *)malloc(sizeof(matrix));

b=(matrix *)malloc(sizeof(matrix));

c=(matrix *)malloc(sizeof(matrix));

a->entry=(double *)malloc(sizeof(double)*n*n);

b->entry=(double *)malloc(sizeof(double)*n*n);

c->entry=(double *)malloc(sizeof(double)*n*n);

buildMatrix(n);

}

void buildMatrix(n) {

printf("\nMatrix A includes: \n");

for (i=0;i<n;i++) {

for (j=0;j<n;j++) {

fscanf(file,"%lf\t",&a->entry[i*n+j]);

if (j<n-1)

printf("%.2lf\t", a->entry[i*n+j]);

else

printf("%.2lf\n", a->entry[i*n+j]);

}

}

printf("\nMatrix B includes: \n");

for (i=0;i<n;i++) {

for (j=0;j<n;j++) {

fscanf(file,"%lf\t", &b->entry[i*n+j]);

if (j<n-1)

printf("%.2lf\t", b->entry[i*n+j]);

else

printf("%.2lf\n", b->entry[i*n+j]);

}

}

}

void matrixMultiply(n) {

for(i=0;i<n;i++) {

for(j=0;j<n;j++) {

float sum=0.0;

for(k=0;k<n;k++)

{

sum=sum+(a[i][k]*b[k][j]);

c[i][j]=sum;

}

printf ("%.2lf\t",c[i][j]);

}

}

}