标签:
代码:
1 #include <cstdio> 2 #include <iostream> 3 4 using namespace std; 5 6 int main(){ 7 8 unsigned char c1 = 0x80; 9 char c2 = 0x80; 10 int a1 = c1; 11 int a2 = c2; 12 cout<<a1<<endl<<a2<<endl; 13 14 return 0; 15 }
输出:
128 -128
分析:
由输出可知,unsigned char向int转换时不会扩展最高位,而char(signed char)则会。
标签:
原文地址:http://www.cnblogs.com/hu983/p/5526879.html