Edik
2009-02-11 12:57:39 UTC
I have a text file which looks something like this:
0 4 10 3 7 9 2
1 7 9 11 4 0 3
etc etc etc (a series of integers on each line)
What I want to do is to take the file, and use ifstream to have my program read it, and subtract the numbers from each other so that the display is the difference between the 2nd and 1st numbers, 3rd and 2nd, 4th and 3rd, etc.
(the first line should end up as 4 6 -7 4 2 -7)
I assume that each line of my text file will be understood as a string when it is read, yes? So, I need to convert my string into a series of integers.
So, how do I convert a string (which is made up of integers separated by spaces) into a series of integers?
Thanks for any help!!