您的位置:首页 > 编程语言 > C语言/C++

【C语言】【面试题】【笔试题】对于char 类型用%u与%d输出结果解析

2015-10-31 18:04 501 查看
#include <stdio.h>
int main()
{
char a = 128;//128=127+1=-128;//因为char类型最大能保存的范围为-128~127
//1000 0000
//11111111 11111111 11111111 1000 0000
printf("%u\n", a);
system("pause");
return 0;
}



#include <stdio.h>
int main()
{
char a = -1;;
//1000 0000
//11111111 11111111 11111111 1111 1111
printf("%u\n", a);
system("pause");
return 0;
}



#include <stdio.h>
int main()
{
char a = -1;
//1000 0000
//11111111 11111111 11111111 1111 1111
printf("%d\n", a);
system("pause");
return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息