fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef struct S {
  5. int a1;
  6. char a2;
  7. } A;
  8.  
  9. int main() {
  10. // your code goes here
  11. A a;
  12. A* ptr;
  13. ptr = &a;
  14. cout << ptr << " " << ptr+1 << "\n";
  15. cout << (ptr+1) - ptr << "\n";
  16. long long size_in_bytes = (char*)(ptr + 1) - (char*)ptr;
  17. cout << size_in_bytes << "\n";
  18. return 0;
  19. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
0x7ffffb9227f0 0x7ffffb9227f8
1
8