I am a beginner in C and wish to know how to convert an array of numbers that represent the bits of a number into the integer it represents.
I searched online but only found char array to int.
I am making converter and need to int array to toggle the bit values from 1 to 0 and vice versa(ie binary). So far i have managed to make the array integers toggle, but I cannot figure out how to change the array of numbers into the single number the array represents. I need this integer so i can convert it into a decimal number which the user can view.
Is there any simple solution to this?
bin= integer variable to store the binary number
arrbin = integer array to store the state of the bit ie(00000000)
for (i = 0; i < 8; ++i )
{
bin = bin + (10 * arrbin[i]);
}
EDIT: I think i see the problem now, instead of the values being implemented every exponent of 10 up, the numbers were only being multiplied by 10. will try and see if this fixes it.
EDIT #2: I dont mean conversion of binary to decimal. I meant conversion of array of numbers ie{1,0,0,0,0,0,0,1) to integer (integer varible = 10000001 not 129)