What is the difference between pointer and address ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between pointer and address ?

21st Dec 2016, 7:14 AM
Amrita.A
Amrita.A - avatar
2 Answers
+ 8
A pointer is used to store the address of another variable. try out the following: int x = 0; // declare variable x int* y; // declare pointer y y = &x; // assign address of x to y & operator in front of variable returns the address of a variable. This address is then stored inside a pointer as shown above. cout << *y; // outputs 0 cout << y; // outputs address of x
21st Dec 2016, 7:20 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
A pointer stores the address of something example....assume I declared a variable int x=4; so the program will store x=4 in a memory location, assume it's 543194981646.....this is x's address now let's create a pointer of x..... int *pnt...pnt =&x This pointers stores the address of x.... Now let's make this easier...assume you are looking for Bucky's home....so you asked someone and he showed you the location....the person who showed you the location is the pointer and the location is the address of Bucky I hope it helped :)
21st Dec 2016, 7:44 AM
Towfique Kabir
Towfique Kabir - avatar