fork download
  1. #include <iostream>
  2. #include <cstdint>
  3.  
  4. using namespace std;
  5. struct A1
  6. {
  7. };
  8.  
  9. struct A2
  10. {
  11. char c;
  12. };
  13.  
  14. struct A3
  15. {
  16. char c[3];
  17. };
  18.  
  19. struct A4
  20. {
  21. char c[9];
  22. };
  23.  
  24. int main() {
  25. cout << "A1 : " << alignof(A1) << endl;
  26. cout << "A2 : " << alignof(A2) << endl;
  27. cout << "A3 : " << alignof(A3) << endl;
  28. cout << "A4 : " << alignof(A4) << endl;
  29. cout << "char : " << alignof(char) << endl;
  30. cout << "int : " << alignof(int) << endl;
  31. cout << "double : " << alignof(double) << endl;
  32. cout << "long double : " << alignof(long double) << endl;
  33. cout << "int64_t : " << alignof(int64_t) << endl;
  34. return 0;
  35. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
A1 : 1
A2 : 1
A3 : 1
A4 : 1
char : 1
int : 4
double : 8
long double : 4
int64_t : 8