Reading numbers from a text file
Dear friends,
there is a text file ( I copied a few lines of it below), I want to read every number in one line and want to insert to a vector. number of columns and lines can change.
How can I do that with using ifstream or any other method?
I will really appreciate any help.
thanks.
Code:
8 8 0.3886 0.2993 0.3997 0.3656 0.3048 1.0000 0.2231 0.1664 0.1887 0.1690 0.2214 -0.3670 10.2611 5.37 4
16 8 0.3410 0.5109 0.7572 0.9174 0.9638 1.0000 0.9823 0.9277 0.7746 0.1978 -1.0000 -0.1390 0.2703 5.07 5
24 8 0.9683 0.9873 0.9772 0.9798 0.9940 1.0000 0.9933 0.9828 0.9762 0.9731 0.9438 -0.0076 0.0006 5.07 2
32 8 0.9610 0.9847 0.9661 0.9820 0.9974 1.0000 0.9954 0.9843 0.9777 0.9848 0.9688 -0.0064 0.0009 5.13 0
40 8 0.9692 0.9759 0.9577 0.9828 0.9935 1.0000 0.9975 0.9829 0.9662 0.9889 0.9751 -0.0059 0.0017 5.33 3
48 8 0.9537 0.9587 0.9442 0.9810 0.9962 1.0000 0.9940 0.9756 0.9628 0.9852 0.9769 -0.0078 0.0022 5.88 7
56 8 0.9626 0.9727 0.9399 0.9700 0.9950 1.0000 0.9955 0.9824 0.9585 0.9762 0.9694 -0.0074 0.0032 6.39 7