#include<iostream>
using namespace std;
int main()
{
unsigned char a=0xA5;
unsigned char b=~a>>4;
unsigned char c = ~a;
cout<<sizeof(a)<<endl;
cout<<sizeof(a>>4)<<endl;
printf("b = %d \n",b);
unsigned char d = (~a);
d>>=4;
printf("%d\n",d);
unsigned char d2 = (~a)>>4;
printf("%d\n",d2);
unsigned char e = (a>>4);
e=~e;
printf("%d\n",e);
return 0;
}
运行结果
1
4
b = 245
5
245
245
问题,为什么
unsigned char d = (~a);
d>>=4;
printf("%d\n",d);
输出5
而
unsigned char d2 = (~a)>>4;
printf("%d\n",d2);
输出245 |