#include <stdio.h>
#include <stdlib.h>
//如果char类型有八位,unsigned char范围是0~255,
//signed char范围是-128~127。
//不带限定符的char类型对象是否带符号取决于具体机器。
//可打印字符总是正值
int main()
{
printf("signed char min = %d\n",-(char)((unsigned char)~0>>1)-1);
printf("signed char max = %d\n",(char)((unsigned char)~0>>1));
printf("signed short min = %d\n",-(short)((unsigned short)~0>>1)-1);
printf("signed short max = %d\n",(short)((unsigned short)~0>>1));
printf("signed int min = %d\n",-(int)((unsigned int)~0>>1)-1);
printf("signed int max = %d\n",(int)((unsigned int)~0>>1));
printf("signed long min = %ld\n",-(long)((unsigned long)~0>>1)-1);
printf("signed long max = %ld\n",(long)((unsigned long)~0>>1));
//printf("unsigned char min = %u\n",UCHAR_MIN);
printf("unsigned
确定C语言各类型变量取值范围(不通过头文件)
最新推荐文章于 2024-03-14 19:49:11 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)