here is the code i have used for getting bits out of a byte, currently its for a character inputted through keyboard, but it can be adopted with any I/O by converting it the other way around, but as i said i think there must be some more proficient method of doing it.
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int bits[8];
int b;
int cnt=7;
char ch;
clrscr();
printf(" Enter a value or character ");
scanf("%c",&ch);
clrscr();
while(cnt>=0)
{
b=ch%2;
bits[cnt]=b;
a=a/2;
cnt--;
}
for(cnt=0;cnt<8;c++)
printf("%d",bits[cnt]);
getch();
}


