Concatenate array elements more then specified range
Hi
I m concatenating specific range of digits that are same from an array "element" . I have problem with range.As in my case the range is col_elem[ii]=4, but it will continue reading the next element if it is the same. My code is:
Code:
int element[8]={0,1,3,3,3,0,1,2};
col_elem[ii]=4;
for (rr=0; rr<col_elem[ii];rr++){
join_tmp[qq]=rr;
while ((element[ii]== element[ii+1]) ) {
join_tmp[qq]= concatenate(rr+1, join_tmp[qq]);
printf("%d\n",join_tmp[qq]);
rr++;
}
qq++;
}
Code:
//FUNCTION TO CONCATENATE INTEGER VALUES OF SAME GROUP IN A COLUMN
unsigned concatenate(unsigned x, unsigned y) {
unsigned pow = 10;
while(y >= pow)
pow *= 10;
return x * pow + y;
}
Code:
I want output like
0
1
33
instead i get
0
1
333
How can i fix it? Thanks