offset.c 262 B

1234567891011121314151617
  1. //
  2. // offset.c
  3. #include <stdio.h>
  4. #include <stddef.h>
  5. struct car
  6. {
  7. char brand[30];
  8. char model[30];
  9. double hp;
  10. double price;
  11. };
  12. int main(void)
  13. {
  14. size_t into = offsetof(struct car, hp); /* offset of hp member */
  15. printf("%zd\n", into);
  16. }