I want to read from a file two complex numbers
(1.1,2) (1.7,3.14)
In the beginning I do this
struct Num { double Re;
double Im;
};
typedef struct Num zesp;
zesp readZ(FILE *wp)
{
char c;
zesp z;
assert(fscanf(wp,"%c%lg%c%lg%c%c",&c,&z.Re,&c,&z.Im,&c,&c));
return z;
}
But now I get a new task, my teacher said that I should use complex.h to read, write, etc. instead of using my type zesp
First I initialize two complex numbers
double complex c1;
double complex c2;
Then I know that normally I will give them value by writing this
double complex z1 = 2.6 + 3.1*I
But how to do this by reading from a file?
(1.1,2) (1.7,3.14)
Edit: Numbers are stored like that
(1.1,2) (1.7,3.14) (2.71,-15)
(4,3.21) (6,7.89)
(10,45)
parenthesis and space between complex numbers