+ 7
[Solved]Why is it giving me two different addresses??
https://code.sololearn.com/cWvem85YcY1I/?ref=app Thanks everyone 😊
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.
+ 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.