fork download
  1. #include <iostream>
  2. #include <type_traits>
  3. using namespace std;
  4.  
  5.  
  6. //3 bytes
  7. struct A{
  8. char b[3];
  9. };
  10.  
  11.  
  12.  
  13.  
  14. int main() {
  15. // your code goes here
  16. //Shouldn't this align each index to an 8-byte address(x8 and x0)?
  17. alignas(8) A a[3];
  18. char c[5] = {1,2,3,4,5};
  19.  
  20.  
  21.  
  22. std::cout << "Address of a1: " << &a << std::endl;
  23. std::cout << "Address of a2: " << &a[1] << std::endl;
  24. std::cout << "Address of a3: " << &a[2] << std::endl;
  25.  
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Address of a1: 0xbfa43780
Address of a2: 0xbfa43783
Address of a3: 0xbfa43786