Data.txt
Heat 1
Lane num Name Nat Time
1 334 John Steffensen AUS 44.82
2 500 Takeshi Fujiwara ESA 46.92
3 651 Dimítrios Régas GRE 46.22
4 352 Chris Brown BAH 44.5
5 1050 Rennyuow TRI 45.7
6 491 Arismendy Peguero DOM 44.92
7 897 Marcin Marciniszyn POL 45.83
8 626 Bastian Swillims GER 45.44
Heat 2
Lane num Name Nat Time
1 351 Avard Moncur BAH 45.27
2 571 Brice Panel FRA 46.02
3 1166 Lewis Banda ZIM 45.47
4 915 Félix Martínez PUR 46.86
5 1151 Jeremy Wariner USA 45.1
6 684 David Gillick IRL 45.35
7 595 Martyn Rooney GBR 45.47
8 846 Hermán López NCA 50.72
I have to read the text file and store each of the details in a structure (struct).
Above, I tried to use the getline function but it seems to be complicating things for me...any help? Maybe I should you sub strings?
And could you please elaborate on this? I am very inexperienced at coding :P
Use stringstreams and the >> operator. It will automatically get rid of the white spaces.
toum: I already extracted the entire line into a string. I can do this for all the lines one by one. I just need to know how to separate out the variables and store them in a string array or struct perhaps.