Hi,
I did a function that get inputs of equations from user but I am trying to get from a 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(); }
can anyone help me how the function read the linear equation from file. assume the file has:
6x + 2y -z = 5
-2x + 4y + z = 8
3x + y + 7z = 3



1Likes
LinkBack URL
About LinkBacks



