@Dave_Sinkula
I used this:
Code:
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include "math.h"
int GetBit(unsigned char byte, unsigned char bit)
{
bit = 1 << bit;
return (byte & bit);
}
int _tmain(int argc, _TCHAR* argv[])
{
unsigned char byte = 0x2B;
int i;
for (i=7;i>-1;i--)
{
int state = GetBit(byte, i);
if (state == 0)
{
printf("%d",state);
}
else
{
state = state/(pow(2,i));
printf("%d",state);
}
}
for(;;)
{
}
}
to test it and it' s just what I wanted! Now I can use a 2 dimension array with unsigned char elements.
I just had to add
Code:
state = state/(pow(2,i));
because without this state had as a value the power of 2 of the location of the bit.
You have been really helpful