Hi im trying to write a function which takes the value of an array from a class with custnum variable and compares it with the other values of the array
lets say if i have 4 custnum ids...and index 0 and 1 of STORE1.custnum is equal it would store those two values in tmp[0][0] and tmp[0][1] ..and to check if STORE1[2].custnum is equal to the previous entries it would compare 2 with 1 with 0. if it is not equal the value will be stored in tmp[1][0]....then we check for STORE1[3].custnum by comparing 3,2 3,1 3,0 index of custnum if it is equal to index 2 it would store it in tmp[1][1] and so on...
how would i go about doing this in a loop
the size of the array of custnum is y.
for example this code only checks the STORE1[0].custnum and STORE1[1].custnum values
Code:
// sets initial value
tmp[0][0].custnum = STORE1[0].custnum;
tmp[0][0].product = STORE1[0].product;
tmp[0][0].quantity = STORE1[0].quantity;
tmp[0][0].month = STORE1[0].month;
tmp[0][0].day = STORE1[0].day;
tmp[0][0].year = STORE1[0].year;
// compares custnum of 0 and 1 index
if(tmp[0][0].custnum = STORE1[1].custnum)
{
tmp[0][1].custnum = STORE1[1].custnum;
tmp[0][1].product = STORE1[1].product;
tmp[0][1].quantity = STORE1[1].quantity;
tmp[0][1].month = STORE1[1].month;
tmp[0][1].day = STORE1[1].day;
tmp[0][1].year = STORE1[1].year;
}
else {
tmp[1][0].custnum = STORE1[1].custnum;
tmp[1][0].product = STORE1[1].product;
tmp[1][0].quantity = STORE1[1].quantity;
tmp[1][0].month = STORE1[1].month;
tmp[1][0].day = STORE1[1].day;
tmp[1][0].year = STORE1[1].year; }