#include<stdio.h>
void printBits(unsigned int num)
{
char bit =0;
for(bit=0;bit<(sizeof(unsigned char) * 8); bit++)
{
num = num >> 1;
}
printf("\n\n");
}
int main()
{
unsigned char n = 0x07;
unsigned char r = 0x00;
unsigned char m = 0x01;
unsigned char i = 0;
printBits(n);
for (i=0; i<sizeof(char)*8; i++)
{
r = r|( (n&m) << (sizeof(char)*8-1) -i);
n=n>>1;
}
printBits(r);
printf("\n\n reverse =%d",r);
}
No comments:
Post a Comment