+ 7

[Solved]Why is it giving me two different addresses??

https://code.sololearn.com/cWvem85YcY1I/?ref=app Thanks everyone 😊

23rd Sep 2020, 5:56 PM
OfcourseitsRohit
OfcourseitsRohit - avatar
3 ответов
+ 7
*p returns the value at address pointed by pointer variable p. p returns the address pointed by p. &p returns the address of p itself.
23rd Sep 2020, 6:03 PM
Avinesh
Avinesh - avatar
+ 1
#include <iostream> using namespace std; int main() { int *p = new int; *p = 5; cout<<*p<<endl; //--> that's mean value of variable cout<<p<<endl; //--> that's mean address of variable, whose pointing pointer cout<<&p; //--> that's mean address of pointers p } //So it gives you two different address, hope you understood.
23rd Sep 2020, 6:08 PM
Rupali Haldiya
Rupali Haldiya - avatar