-
Yep, i was at uni and i don't have a compiler there, it should be the other way around
*(ib+=*ia==*ib)=*ia++
which means the target will only increment when the values are equal.
Notice the target iterator ib will the last result value, meaning you cut of the last numbers, also ib<&both[MAX_LENGTH_BOTH] not ia
-
k i made the changes:
for(int* ia=both,* ib=both;ib<&both[MAX_LENGTH_BOTH];*(ib+=*ia==*ib)=*ia++;
get a parse error somewhere in there. :(
D!m
-
did you forget the closing parentesis for for( ; ; );
-
Put the last one in and the output is even crazier...this is what i get now:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-
ok this should work
for(int* ia=both,* ib=both;ib<&both[MAX_LENGTH_BOTH];ib+=*ia!=*ib)*ib=*ia++;
-
Almost there....it does remove the doubles...but when printing out the array using this code:
for(j = 0; j <= (MAX_LENGTH_BOTH); j++)
cout << both[j] << " ";
It places the the doubles along with some other numbers at the end of the array...how would i resize the array based on how many doubles there were found.
Going from something like this:
-1 0 0 2 2 3 4 4 5 6 7
To:
-1 0 2 3 4 5 6 7
Thanx for stickin with me kedaman...
-
depends.
if you treat both as a buffer and have say a terminator t, then t=ib, and you iterate like this:
for(int*j=both;j<t;j++)
cout << *j << " ";
-
k it seems to be working well...thank you for your help.
Have a look at my other post...maybe you can help there also.
Thanx,
D!m