Hello all, and thank you for taking the time to help me with this.
I am relatively new to C++ programming and am in need of some help.
I have a text file containing 2 columns of data. I would like to write a program to look at the file and check to see if any of the values in the first column repeat. If they do, then it should sum up the corresponding second column.
for example the text file may look like this:
1 2
2 1
3 1
4 5
3 2
4 1
5 6
15 1
I want the program to output:
1 2
2 1
3 3
4 6
5 6
15 1
I can read the data in using the following snippet of code;
/* this is the part where I am lost
if first = any previous value then sum all of those values = secondsum
if first is the only one of its kind then secondsum = second
*/
outFile11 << first << "\t" << secondsum << endl;
outFile11.flush();