I am having a trivial trouble on how to create three different arrays from a text file. I am a beginner in C++.
I have a .txt file containing a string of 'float' values as below:
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
//----------------------
Now, I want to make three arrays, p1[], p2[], and p3[] from them, so that
p1[] has elements from line: 1, 4, 7, ...,
p2[] has elements from line: 2, 5, 8, .., and
p3[] has elements from line: 3, 6, 9,... of the .txt file.
My original file has a huge amount of data, so I would have to use a loop, but I cannot think of a way to fill my arrays as described.
Can anyone help me please? I would appreciate greatly.