将一个字节反转

 

 

 1 #include <stdio.h>
 2 
 3 int main()
 4 {
 5     unsigned char a = 0xaa, b = 0;
 6     char i = 0;
 7     for (i = 0; i < 8; i++)
 8     {
 9         b |= (((a >> i) & 0x01) << (7 - i));
10     }
11     printf("b = 0x%x\n", b);
12     return 0;
13 }

 

posted @ 2013-08-30 17:57  ★行云流水★  阅读(281)  评论(0编辑  收藏  举报