Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int askUserFn();
- int displayPtr(int& n);
- int main()
- {
- int x = askUserFn();
- int y = askUserFn();
- // int *ptrX = &x;
- // int *ptrY = &y;
- displayPtr(x);
- displayPtr(y);
- }
- int askUserFn()
- {
- std::cout << "Enter a number: ";
- int x;
- std::cin >> x;
- return x;
- }
- int displayPtr(int& n)
- {
- int *ptrN = &n;
- std::cout << "The pointer has value " << *ptrN << " and is stored in address " << ptrN << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement