try_pointer.cpp 307 B

1234567891011121314151617181920
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n = 5;
  6. cout << &n << endl;
  7. int *ptr = &n;
  8. cout << ptr << endl;
  9. cout << *ptr << endl;
  10. *ptr = 10;
  11. cout << ptr << endl;
  12. cout << *ptr << endl;
  13. // the value of n also changed
  14. cout << n << endl;
  15. return 0;
  16. }