data input from file

hi

how would i get individual data or arrays from a .txt file.
all the tutorials i find the program draws all the data from the file as one string.if this was the data in the .txt file for example:

10 202 5 991
16 231 6 702
15 211 8 861

what i would like to do is get to take the first line and put each number in its own array. a = [10] b - [202]... then use that info . after it has been processed the program must move on to the next line. could you please assist me with any info or tutorials in relation to this.
What do these numbers represent? Maybe instead of putting each column in its own array it would be better to group them in a struct and store the data in an array of such structs. Also, if you don't know how many lines there are in the file, an array won't be enough... You see, an array's size is fixed and determined on compile-time. Maybe a vector would be a better approach. What do you think?

Info on structs -> http://cplusplus.com/doc/tutorial/structures/
Info on vectors -> http://cplusplus.com/reference/stl/vector/
Last edited on
http://www.cplusplus.com/doc/tutorial/files/

Personally, I find that particular tutorial to be really helpful. Also, reading up on the getline command is also highly recommended.

Where exactly are you getting stuck? Are you having problems accessing the text file?
Topic archived. No new replies allowed.