Loading...
Select Version
&pagelevel(4)&pagelevel
Definition | #include <stddef.h> size_t offsetof(type,component);
|
Return val. | Offset of the structure component from the start of the structure in bytes. |
Note | If the specified structure component is a bit field, the behavior is undefined. |
Example | #include <stdio.h> #include <stddef.h> struct S1 { char c; int i; double d; }; int main(void) { typedef struct S1 t_s1; printf("offsetof(struct S1, c) = %d\n", offsetof(struct S1, c) ); printf("offsetof(struct S1, i) = %d\n", offsetof(struct S1, i) ); printf("offsetof(struct S1, d) = %d\n", offsetof(struct S1, d) ); printf("\n"); printf("offsetof(t_s1, c) = %d\n", offsetof(t_s1, c) ); printf("offsetof(t_s1, i) = %d\n", offsetof(t_s1, i) ); printf("offsetof(t_s1, d) = %d\n", offsetof(t_s1, d) ); printf("\n"); return 0; } |