Hello, I am a beginner and need some urgent help. I will really appreciate if anyone can refer me to the specific topics which I should read to comprehend the topics that I am gonna ask.
This is I need to do-
1. I am working with complex numbers (real and imaginary). The input file will contain an array like this:
R0 I0 R1 I1 R2 I2 R3 I3
where each pair (R I) represents the real and imaginary values of each complex numbers. I know how to create my own data type for complex numbers and I already did that. Now, I want to create an array "a" of complex numbers where a[0]=R0 +i I0, a[1]= R1 +i I1 and a[2]=R3 +i I3. The values are required to be read from text file.
How can I implement that?
Thanks in advance. I didn't do file operations before. So, it will be really helpful to get some help. I would really appreciate if atleast anyone can refer me to the class or functions related to file op which will be necessary to do this.
Here, I can declare arrays of complex number and I can take the respective values from user. BUT my problem is, I have a text file like that:
0 1 2 3 3 4 3 5 4
Here, the complex numbers are c[0].real=1, c[0].img=2, c[1].real=3, c[1].img=3, c[2].real=4, c[2].img=3, c[3].real=5, c[3].img=4
How can I do that? I know how to read from file and how to store values in file. However, in this case, I need to know what integer from the file I am reading. Because the first integer (0) is not a part of complex numbers. Starting from 1, each pair will represent one complex number. How can I implement that? It seems that I need to run a loop and whenever I came across an integer in the file, I would need to store it in appropriate location in my array.