I cant think right now and.....
Could someone write a little C code that loops through chars(1 byte,8 bits) and separates them into bits, in like other variables. I tried using shifts but if didnt work 2 good, Thanks alot
How about something like this: Your input char is c.
etc.
Or even cleaner:
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
bool bit1 = c & 0x01;bool bit2 = c & 0x02;bool bit3 = c & 0x04;
etc.
Or even cleaner:
bool bits[8];for( int i = 0; i < 8; i++ ){ bits = c & ( 1 << i );}
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
void BitSeperator(unsigned char source,char *dest) // dest = pointer to char[8]
{
for (char i=0;i<8;i++)
{
dest = source&1;
source >>=1;
}
}
I hope that''s the right code for you
Visit our homepage: www.rarebyte.de.st
GA
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement