Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
To work with pointers, you need two special operators: the Address-of operator & and the Dereference operator *.
int* ptr = &x;Gets the memory address where variable x is stored.
int value = *ptr;Gets the value stored at the address pointed to by ptr.
int x = 10; int* ptr = &x; // ptr stores address of x cout << ptr; // Output: 0x7ff... (Address) cout << *ptr; // Output: 10 (Value at address) *ptr = 20; // Changes x to 20 indirectly!