fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstdint>
  4.  
  5. using namespace std;
  6.  
  7. void print_var(char name, int& value) {
  8. uintptr_t addr = reinterpret_cast<uintptr_t>(&value);
  9. printf("%c value = %d, address = %p\n", name, value, addr);
  10. }
  11.  
  12. void my_proc(int& b) {
  13. print_var('b', b);
  14. b = 7;
  15. }
  16.  
  17. int main() {
  18. int a = 5;
  19. print_var('a', a);
  20. my_proc(a);
  21. printf("after my_proc\n");
  22. print_var('a', a);
  23. return 0;
  24. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
a value = 5, address = 0x7ffddaa70aec
b value = 5, address = 0x7ffddaa70aec
after my_proc
a value = 7, address = 0x7ffddaa70aec