I'm trying to implement the multiplication of two matrices something like this picture in c langage.
I want to read the numbers from a text file of x and store it later in an array the code that i tried is below
So the problem that I have is when i use the static method Complex x[4] = { { 1,0 },{ 0,-1 },{ 1,1 },{ 4,-1 } };
it's work but when i want to read it from input.txt Complex x[4]
it does not work what i missed.
typedef struct Complex
{
double real;
double image;
}Complex;
int main()
{
Complex x[4] = { { 1,0 },{ 0,-1 },{ 1,1 },{ 4,-1 } };
Complex y[4] = { { 0,1 },{ 1,-1 },{ 2,-3 },{ 4,0 } };
FILE *input;
input = fopen("input.txt", "r");
if (sensorInput == NULL ) {
printf(stderr, "Cannot open file\n");
return 1;
}
else {
for (i = 0; i<4; ++i)
{
fscanf(sensorInput, "%lf + j*%lf\t", &x[i]);
printf("\n");
}
}
}
input.txt
1,0
0,-1
1,1
4,-1