Mail Archives: djgpp/1999/02/07/02:04:15
> What the hell header is ptrdiff_t typedef'd in? I can't find it --
> it isn't in stdlib.h where I thought it would be, and there is no
> info node for it to enable me to track it down that way.
<stddef.h>
You should try "grep" next time.
> I can't even recall a C function that involves ptrdiff_t.
You won't. ptrdiff_t is the type of the result of subtracting two
pointers, as defined by the compiler. Normally, when you subtract two
pointers in C, the result is a number - the difference (scaled by the
size of the type the pointers point to - array arithmetic, you know)
between them. In this example, z would be 50:
int x[100];
int *y = &(x[50]);
ptrdiff_t z = y - x;
- Raw text -