(ANSI Standard)
#include <stddef.h> offset = offsetof(type,member);
struct TAG
The "offsetof" macro expands to an expression giving the offset (in bytes) of a member of a structure type.
The "member" argument is typically the name of a member of the given type of structure. The precise technical requirements for member are these: if we were to declare a structure S with
static type S;
then the expression &(S.member) must evaluate to an address constant.
size_t offset; offset = offsetof(struct tm,tm_year);
Copyright © 1996, Thinkage Ltd.