fork(3) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i = 5;
  8. int* p;
  9. cout << "pointer p is " << *p << " at " << (void*)&p << " and size is " << sizeof(p) << endl;
  10. p = new int;
  11. //*p = 10;
  12. cout << "pointer p is " << *p << " at " << (void*)&p << " and size is " << sizeof(p) << endl;
  13. delete p;
  14.  
  15. p = &i;
  16. cout << "pointer p is " << *p << " at " << (void*)&p << " and size is " << sizeof(p) << endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
pointer p is 1752444 at 0xbfe90ffc and size is 4
pointer p is 0 at 0xbfe90ffc and size is 4
pointer p is 5 at 0xbfe90ffc and size is 4