#include <stdio.h> void main() { char c=256; int a=c; printf("%d\n",a); }

日期:2012-10-12 16:13:48 人气:1

#include <stdio.h> void main() { char c=256; int a=c; printf("%d\n",a); }

char c的取值范围是-127到127。所以当c=256时,溢出了。256的16进制为100,高位1溢出,所以,输出为0 当c为255时,16进制是ff,根据补码,就是-1。所以输出为-1
    A+
热门评论