Thursday, July 9, 2009

C++ Array help!?

I have an input file of fifteen lines, followed by a space, and 6 more lines...


1


2


3


4


...


15


%26lt;space%26gt;


1


2


...


6


I can load my array with the entire data of the input file, that's not the problem. However, I want to load the last six lines (after the space) into a completely different array for passing. How can I do that?


Thank you...

C++ Array help!?
I would write a method to wrap this. Just read in the file one line at a time and exit the method when you see a space or EOF. The method would look something like this:





void get_stuff(file_in_buffer, array)


{


Read in a line


if the line is blank or reached EOF - return


else push the line into your array


}





call it like this





open file


get_stuff(file_read_buffer, array_one);


get_stuff(file_read_buffer, array_two);


close file





That work for you?





Cheers!
Reply:Once you load the 1st 15 lines and hit the space, switch out the arrays and read the others into the next array.


No comments:

Post a Comment