ptrdiff_t is a signed integer type capable of representing the difference between pointers to elements of the same array. Use it for large differences that may be negative. section 5.2
Choose the type according to the quantity being represented:
- Use size_t for sizes, cardinalities, and ordinal numbers. section 5.2
- Use ptrdiff_t for large signed differences. section 5.2
- Both size_t and ptrdiff_t are defined in stddef.h. section 5.2
Table 5.2. Some semantic arithmetic types for specialized use cases (view table figure)
| Type |
Header |
Context of definition |
Meaning |
|---|---|---|---|
| size_t | stddef.h | type for “sizes” and cardinalities | |
| ptrdiff_t | stddef.h | type for size differences | |
| uintmax_t | stdint.h | maximum width unsigned integer, preprocessor | |
| intmax_t | stdint.h | maximum width signed integer, preprocessor | |
| time_t | time.h | time(0), difftime(t1, t0) | calendar time in seconds since epoch |
| clock_t | time.h | clock() | processor time |
Compare ptrdiff_t with size_t and other semantic arithmetic types by header, context, and meaning. section 5.2

