Last active
May 22, 2021 10:02
-
-
Save markusbuchholz/2cec391b9150e1f955b4de3945442af9 to your computer and use it in GitHub Desktop.
pointer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() | |
{ | |
int myNumber = 1234; | |
int *ptr_myNumber = &myNumber; | |
std::cout << " value stored in myNumber : " << myNumber << std::endl; | |
std::cout << " address of myNumber : " << &myNumber << std::endl; | |
std::cout << " *ptr_myNumber : " << *ptr_myNumber << std::endl; | |
std::cout << " value stored in ptr_myNumber : " << ptr_myNumber << std::endl; | |
// after thecompilation and run and you can expect similar output | |
// NOTE: "address of myNumber" AND "value stored in ptr_myNumber" - ARE THE SAME !! | |
/*---------------------------------------------- | |
value stored in myNumber : 1234 | |
address of myNumber : 0x7ffc0fecd71c | |
*ptr_myNumber : 1234 | |
value stored in ptr_myNumber : 0x7ffc0fecd71c | |
----------------------------------------------*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment