align.c 504 B

1234567891011121314151617181920212223
  1. // align.c -- using _Alignof and _Alignas (C11)
  2. #include <stdio.h>
  3. int main(void)
  4. {
  5. double dx;
  6. char ca;
  7. char cx;
  8. double dz;
  9. char cb;
  10. char _Alignas(double) cz;
  11. printf("char alignment: %zd\n", _Alignof(char));
  12. printf("double alignment: %zd\n", _Alignof(double));
  13. printf("&dx: %p\n", &dx);
  14. printf("&ca: %p\n", &ca);
  15. printf("&cx: %p\n", &cx);
  16. printf("&dz: %p\n", &dz);
  17. printf("&cb: %p\n", &cb);
  18. printf("&cz: %p\n", &cz);
  19. return 0;
  20. }