Loading...
Select Version
&pagelevel(4)&pagelevel
Definition | #include <stddef.h> size_t offsetof(typ, komponente);
| |
Returnwert | Abstand der Strukturkomponente vom Strukturbeginn in Bytes. | |
Hinweis | Ist die angegebene Strukturkomponente ein Bitfeld, ist das Verhalten undefiniert. | |
Beispiel | #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;
}
| |