c 语言无符号类型使用注意,类型升级

#define SS sizeof(int)
  5 int main()
  6 {
  7
  8             int a = -1;
  9
10             if( a < SS){
11 // 不会输出,因为 ss 是为符号类型。而 a 是 是有符号类型的,两个比较
12 // 产生了,算术运算副的升级,       
13             printf("-----------<<<%d\n",a);
14
15             }
16             if(a<0){// 会输出,因为没有产生,计算的升级
17             printf("<<<--------%d\n",a);
18              }
19             printf("hello world\n");
20             return 0;
21
22
23 }

猜你喜欢

转载自aircoder.iteye.com/blog/1915567
今日推荐