Checking to see if the value has looped?
Code:
for (z=0; z <= iLength; z++)
{
for (i=0; i <= 6; x=x+6, i++, y++)
{
//cout << char( bin_dec(binnum) ) << endl;
sixbit[0] = sOutput3[0+x];
sixbit[1] = sOutput3[1+x];
sixbit[2] = sOutput3[2+x];
sixbit[3] = sOutput3[3+x];
sixbit[4] = sOutput3[4+x];
sixbit[5] = sOutput3[5+x];
sixbit[6] = '\0';
strcpy(sixbit2,sixbit);
// s64bitenc[y] = char( bin_dec2(sixbit,sixbit2) );
iLoopTest1 = bin_dec2(sixbit,sixbit2);
if (iLoopTest1 != iLoopTest2)
{
strcat(s64bitenc,itoa(bin_dec2(sixbit,sixbit2),sixbit2,10));
strcat(s64bitenc," ");
iLoopTest2 = iLoopTest1;
iLoopTest1 = -5;
}
else
{
break;
break;
}
}
}
If I use it without the if and the else
instead of:
Code:
if (iLoopTest1 != iLoopTest2)
{
strcat(s64bitenc,itoa(bin_dec2(sixbit,sixbit2),sixbit2,10));
strcat(s64bitenc," ");
iLoopTest2 = iLoopTest1;
iLoopTest1 = -5;
}
else
{
break;
break;
}
I use
Code:
strcat(s64bitenc,itoa(bin_dec2(sixbit,sixbit2),sixbit2,10));
strcat(s64bitenc," ");
Like I did before I added the ifs, then I get this for output if the input was "0100100001100101011011000110110001101111":
18 6 21 44 27 6 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
for output.
Using the if, 18 6 21.
The desired output for what I mentioned up there would be "18 6 21 44 27 6 15" by converting the binary value of every 6 characters into a number.
How do I get rid of all those zeros, easily?