<limits.h> - C语言标准库
来源:互联网 发布:莎拉 巴雷斯坦 知乎 编辑:程序博客网 时间:2024/05/17 02:26
limits.h头中确定各种变量类型的各种属性。在这个头中定义的宏限制的char,int和long类型,如各种变量的值。
这些限制指定一个变量,无法存储任何值超越这些限制,例如一个无符号的字符最多可以存储的最大值为255。
库宏
下面的值是特定于实现定义#define指令,但这些数值可能没有任何比这里给出更低(小)。
例子
下面的例子显示的几个常量定义在limit.h文件的用法。
#include <stdio.h>#include <limits.h>int main(){ printf("The number of bits in a byte %d", CHAR_BIT); printf("The minimum value of SIGNED CHAR = %d", SCHAR_MIN); printf("The maximum value of SIGNED CHAR = %d", SCHAR_MAX); printf("The maximum value of UNSIGNED CHAR = %d", UCHAR_MAX); printf("The minimum value of SHORT INT = %d", SHRT_MIN); printf("The maximum value of SHORT INT = %d", SHRT_MAX); printf("The minimum value of INT = %d", INT_MIN); printf("The maximum value of INT = %d", INT_MAX); printf("The minimum value of CHAR = %d", CHAR_MIN); printf("The maximum value of CHAR = %d", CHAR_MAX); printf("The minimum value of LONG = %ld", LONG_MIN); printf("The maximum value of LONG = %ld", LONG_MAX); return(0);}
让我们编译和运行上面的程序,这将产生以下结果:
The number of bits in a byte 8The minimum value of SIGNED CHAR = -128The maximum value of SIGNED CHAR = 127The maximum value of UNSIGNED CHAR = 255The minimum value of SHORT INT = -32768The maximum value of SHORT INT = 32767The minimum value of INT = -32768The maximum value of INT = 32767The minimum value of CHAR = -128The maximum value of CHAR = 127The minimum value of LONG = -2147483648The maximum value of LONG = 2147483647
0 0
- <limits.h> - C语言标准库
- C语言标准库limits.h &float.h
- <<C标准库>>:<limits.h>
- C 标准库 —— limits.h
- C语言标准库概览详述[3]-实现限制<limits.h>,<float.h>
- C语言标准库 - limits.h & float.h 固定数值常量
- C语言中的<limits.h>
- C标准库参考指南系列译文(5)limits.h
- Linux下C库学习 - limits.h
- C语言标准库--math.h
- C语言标准库--math.h
- C语言标准库 - stdio.h
- <ctype.h> C语言标准库
- C语言标准库之<float.h>
- C语言标准库之 <assert.h>
- c语言的头文件#include <limits.h>
- c语言的头文件#include <limits.h>
- C语言专题——标准库math.h
- 成长小计-Swift重写frame的set方法
- 解压文件夹
- Yii render
- Suricata.yaml
- iOS开发之图片旋转
- <limits.h> - C语言标准库
- 从结构体成员获取结构体地址的方法
- Freemaker初接触(三)基本类型和list和map的遍历
- JAVA程序单实例运行的实现方法
- socket连接设置超时的几种方法
- 附加数据库
- rancheros学习记录--从安装开始
- 08_MinNumberInRotatedArray旋转数组的最小数字
- 打开一个新的activity并关闭当前activity,以及intent的用法