Hi all,
I was hoping for some help and hints to the problem i'm facing now.
Right now i have a a 2D array which stores the elements:
22Jan11 180
11Feb11 111
22Jan11 90
22Jan11 30
25Jan11 110
I'm trying to basically add up the the value of the duplicate records and store it in the text file which will then be:
22Jan11 300
11Feb11 111
25Jan11 110
I'm not sure as how to go about adding and replacing the records. I've tried the following nested for loop but it's not working properly
for( int x = 0; x < arraysize; x++)
{
for( int j = x+1; j < i; j++)
{
if( array2[x][0] == array2[j][0] )
{
add1 = atoi(array2[x][1].c_str());
add2 = atoi(array2[j][1].c_str());
add3 = add1 + add2;
ss << add3 << endl;
myfile1<<array2[x][0]<<":"<< ss.str();
ss.str("");
}
else
;
}
Hoping for some hints or direction and hopefully I'm still able to use arrays to get it done. Thanks alot!