c语言 有符号整型和无符号整型用%u输出结果都一样,而短整型又不同???

int a=-1;
printf("a=%d\n",a);
printf("a=%u\n",a);

printf("\n");

unsigned int b=-1;
printf("b=%d\n",b);
printf("b=%u\n",b);

printf("\n");

short int c=-1;
printf("c=%d\n",c);
printf("c=%u\n",c);

printf("\n");

unsigned short int d=-1;
printf("d=%d\n",d);
printf("d=%u\n",d);

若是带符号的数【负数】用u%输出值是会改变的,若是正数也就不介意了,短整型用u%输出时也是要看是负数还是正数的,这三种要是全用d%输出时只要不超出所能表示的范围,其值是不会改变的。
温馨提示:答案为网友推荐,仅供参考
相似回答