12. <limits.h> Implementation-defined Integral Type Limits
The header <limits.h> defines constants for the sizes of integral types.
CHAR_BIT | number of bits of char |
CHAR_MIN, CHAR_MAX | minimum and maximum values of char |
SCHAR_MIN, SCHAR_MAX | minimum and maximum values of signed char |
SHRT_MIN, SHRT_MAX | minimum and maximum values of short |
INT_MIN, INT_MAX | minimum and maximum values of int |
LONG_MIN, LONG_MAX | minimum and maximum values of long |
UCHAR_MAX | maximum value of unsigned char |
USHRT_MAX | maximum value of unsigned short |
UINT_MAX | maximum value of unsigned int |
ULONG_MAX | maximum value of unsigned long |
12. limits.h
l limits.c
#include <stdio.h> #include <limits.h> void main() { printf("%d\n", CHAR_BIT); // 8 printf("%d %d\n", CHAR_MIN, CHAR_MAX); // -128 127 or 0 255 printf("%d %d\n", SCHAR_MIN, SCHAR_MAX); // -128 127 printf("%d %d\n", SHRT_MIN, SHRT_MAX); // -32768 32767 printf("%d %d\n", INT_MIN, INT_MAX); // -2147483648 2147483647 printf("%ld %ld\n", LONG_MIN, LONG_MAX); // -2147483648 2147483647 printf("%u\n", UCHAR_MAX); // 255 printf("%u\n", USHRT_MAX); // 65535 printf("%u\n", UINT_MAX); // 4294967295 printf("%lu\n", ULONG_MAX); // 4294967295 }
> cl limits.c && limits
……
-128 127
……
> cl -J limits.c && limits
……
0 255
……
No comments:
Post a Comment