fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void func(){
  5. cout << "Hello World!" << endl;
  6. }
  7.  
  8. int main(){
  9. {
  10. int i;
  11. int *p = &i;
  12.  
  13. cout << "변수 i의 주소: &i = " << &i << endl;
  14. cout << "포인터 p의 값: p = " << p << endl;
  15. cout << "포인터 p의 주소: &p = " << &p << endl;
  16. }
  17.  
  18. cout << "====" << endl;
  19.  
  20. {
  21. void (*ptr)() = func;
  22. cout << "함수 func의 주소: &func = " << reinterpret_cast<const void *>(&func) << endl;
  23. cout << "함수 func의 주소 (다른 방법): func = " << reinterpret_cast<const void *>(func) << endl;
  24. cout << "포인터 ptr의 값: ptr = " << reinterpret_cast<const void *>(ptr) << endl;
  25. cout << "포인터 ptr의 주소: &ptr = " << &ptr << endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 4392KB
stdin
Standard input is empty
stdout
변수 i의 주소: &i = 0x7ffeeb2ba46c
포인터 p의 값: p = 0x7ffeeb2ba46c
포인터 p의 주소: &p = 0x7ffeeb2ba470
====
함수 func의 주소: &func = 0x559b27b933c0
함수 func의 주소 (다른 방법): func = 0x559b27b933c0
포인터 ptr의 값: ptr = 0x559b27b933c0
포인터 ptr의 주소: &ptr = 0x7ffeeb2ba470