这个程序为什么是这个结果啊

来源:百度知道 编辑:UC知道 时间:2024/06/04 13:44:21
main()
{ unsigned short a=65536;
int b;
printf("%d\n",b=a);}

为什么是0 而不是65536

65536也就是2^16,表示成二进制是1后面16个0,但unsigned short本身只有16位,前面的1就被截断了,只读进16个0,所以a本身的值就是0,赋给b的当然也是0了

http://lklovey.blog.163.com/blog/static/35687331200811289541252/