How can i deal the numbers from the file? Like I know if you have an array[1,2,3] and you type array[2] you will the number from the third location. I was wondering if there was a way to do that with the contents of the file. Please help me out guys, I'm so lost.
PS i changed the thread slightly so thats prolly why the previous comments seem off a little.
Will that work if all three of the matrices are in the same file tho? I just dont understand how to load em up and multiply them since there are multiple ones per file.
Just load the first one, then keep advancing through the file until you get the next number, which should be the start of the second one, and repeat. It's not really different from reading single numbers, you just have a bunch of numbers you are reading in a row now.
So if i load the file with the matrices above it will just read the numbers in order? So i'd have to make a program to read the numbers and to understand to put them into matrices if i understand correctly.
Would someone happen to have a link to an example of this? I can sort of understand but it would be great to see it done.
No i dont. I dont understand how to take the numbers in the file above and input them into a matrix in my program. I know how to use fstream and whatnot to get the data from the file but i have no idea how to use it correctly.
So I've been looking into this more and i think what i need to do is be able to "target" the individual numbers within the file to be able to use them appropriately in the file. I'm not sure however how to get the numbers individually. Is there some sort of operator that can just select numbers at certain locations in the file?
No, all you need is a function that will read an array from any given input stream. It should not care where in the stream you are -- it is sufficient that the stream pointer is somewhere immediately before the complete definition of a matrix.
Try doing this:
1 2 3 4 5
istream& operator >> ( istream& ins, my_matrix_type& m )
{
// Stuff that reads a matrix from ins goes here. //
return ins;
}