try_pointer.cpp 409 B

12345678910111213141516171819202122232425
  1. #include "try_pointer.hpp"
  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. char letter = 'a';
  16. char *l_ptr = &letter;
  17. print(l_ptr, 'c');
  18. print(ptr, 'i');
  19. return 0;
  20. }