fork download
  1. #include <iostream>
  2. #include <cstdint>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char a, b;
  9.  
  10. cout << (void *)&a << endl;
  11. cout << (void *)&b << endl;
  12. cout << std::min(std::uintptr_t(&b) - std::uintptr_t(&a), std::uintptr_t(&a) - std::uintptr_t(&b)) << endl;
  13. cout << (&a + 1 == &b) << endl; //1 or 0
  14. cout << (&b + 1 == &a) << endl; //0 or 1
  15. }
Success #stdin #stdout 0s 4724KB
stdin
Standard input is empty
stdout
0x7fff948bf6c7
0x7fff948bf6c6
1
0
1