2 1 3 6 0 9 0
2 9 5 0 0 8
3 10 0 6 0 6
3 1 1 0 4 0 8
2 1 7 0 0 8
3 5 0 4 0 5
4 1 3 10 0 0 7
2 5 7 0 2 0
3 8 6 0 0 7
5 1 4 0 9 8 0
2 6 2 0 0 7
3 10 0 5 0 5
6 1 2 2 0 8 0
I have many text files. The format is like the above one. I hope to store each column data to different array, e.g., col01[5] ={2,3,4,5,6}
(corresponding to the 1st column). How can I do this? col02[15] ={1,2,3......}
(corresponding to the 2nd column data).
The number in the first column is not fixed and the position is also random. For example, the numbers in the first column are randomly located in some lines. The column number is fixed. It may be in the following format:
2 1 3 6 0 9 0
2 2 9 5 0 0 8
3 10 0 6 0 6
3 1 1 0 4 0 8
2 1 7 0 0 8
5 3 5 0 4 0 5
4 1 3 10 0 0 7
2 5 7 0 2 0
3 8 6 0 0 7
5 1 4 0 9 8 0
2 6 2 0 0 7
3 10 0 5 0 5
6 1 2 2 0 8 0
I tried to use istringstream
and getline
but it is too complicated. Thanks