Read coefficients of linear equations from file and use jacobi method

hi;

i did a function that get inputs of equation from user but i want to get from file

Code:

`void getInput( int numUnKnowns, double** mat ){`

int i, j;

printf

(

"\nEnter values for the specified row and column below ...\n"

"(The last column is the value for the RHS of the equation.)\n"

);

for( i = 0 ; i < numUnKnowns ; i++ )

{

mat[i] = (double*) malloc( (numUnKnowns+1)*sizeof(double) );

puts("");

for( j = 0 ; j < numUnKnowns+1 ; j++ )

{

printf("matrix[%d][%d] : ", i, j);

if( scanf("%lf", &mat[i][j]) != 1 )

{

--j;

puts("Bad entry ... try again with a 'real' number.");

}

while( getchar() != '\n' ) ; /* flush stdin ... */

}

}

printf("\nThe matrix entered:\n\n");

for( i = 0 ; i < numUnKnowns ; i++ )

{

for( j = 0 ; j < numUnKnowns+1 ; j++ ) printf("%+9f ", mat[i][j]);

puts("");

}

printf("\nPress 'Enter' to start iteration ... ");

getchar();

}

let file :

7a - 2b + c + 2d = 3

2a + 8b + 3c + d = -2

-a + 5c + 2d = 5

2b - c + 4d = 4

can any one help me how function read from file.

thanks