ptrdiff_t
is the result of subtracting two pointers.
size_t
is the unsigned integer result of the sizeof keyword.
wchar_t
is an integer type of the size of a wide character constant.
NULL
is the value of a null pointer constant.
offsetof(
type,
member-designator)
This results in a constant integer of type size_t
which is the offset in bytes of a structure member from the beginning of the structure. The member is given bymember-designator, and the name of the structure is given in type.
Example:
#include<stddef.h> #include<stdio.h> int main(void) { struct user{ char name[50]; char alias[50]; int level; }; printf("level is the %d byte in the user structure.\n"), offsetof(struct user,level)); }
The output should be:
level is the 100 byte in the user structure.