in reply to Bit of maths between two files

What do you want when you get done? A file with the sum of each line from both files, printed 1 to a line? If so, why do the original files need to be combined into one at all? Why not do something like this:

open first file for input
open output file for write
split the line
add up the line elements
print the result to output file
open second file and follow the same steps above, continuing to write to the same output file you still have open

While I could probably use the homework practice myself, I'm deliberately not doing the code for you-- looks like you can handle that. Just suggesting a different way to think about your problem. Or demonstrating I don't understand it.

Good Luck.



Replies are listed 'Best First'.
Re^2: Bit of maths between two files
by Anonymous Monk on Aug 05, 2004 at 15:17 UTC
    sorry should have been clearer, need to add each x element from the 2 file to one another then y and z. Not the sum of each line!