offsetof Function (Macro)

stddef.h

#define offsetof(type,member) ((unsigned long) &(((type*)0)->member))

Returns the offset of a member in a structure.

offsetof is a macro which returns the offset of a member in a structure type. The type can either be defined through typedef, or preceded by struct, as usual.


Deprecated alias: OFFSETOF


See also: sizeof, typeof