Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- // More code tutorials at brandonhok.com
- // pointers and how they work
- int main()
- {
- int hotdog = 4;
- int* hotdogPoint = &hotdog;
- int* corndogPoint;
- corndogPoint = &hotdog;
- // main value
- std::cout << hotdog;
- // prints addresses because of &
- std::cout << std::endl << hotdogPoint
- << std::endl << corndogPoint << std::endl;
- // prints value of address because of *
- std::cout << *hotdogPoint << std::endl;
- std::cout << *corndogPoint << std::endl;
- // when used together, they are addresses
- std::cout << *&hotdogPoint << std::endl << &*hotdogPoint;
- system("pause");
- // try creating your own pointers and using different values
- // can you develop a hamburger pointer that uses a larger number?
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement