I have an Array as (filled with zeros and ones) -> ArrayWithContent[5] = {1,0,0,1,1};
Now I want this to be converted into an variable so I can read out the total value of this.
0001 0011 = 19
for(i=0; i<5; i++)
{
OneValue = ArrayWithContent[i];
Variable = OneValue;
Variable >>= 1; // Send the zero or one to right.... continue to fill it up
}
Display Content of Variable I now want it to show the value 19.
I know I does this wrong, what is the correct way? Pointers and Addresses?
Here:
(Variable << 1)shifts the current value ofVariableone bit to the left.... | ArrayWithContent[i]replaces the least-significant bit of the shifted value withArrayWithContent[i].Variable = ...assigns the result back toVariable.