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