In one line statement what is the difference between *cptr and cptr. How could you say .
In pointer section
@Nikhil-Aggarwal-2320066674901389
It totally depends how they are declared and how they are being used. Please give a reference code and I can explain according to it.
pls reply my doubt
@Nikhil-Aggarwal-2320066674901389
As discussed around 32 mins in the webinar
char ch = ‘A’ ;
cout << &ch << endl;
int* cptr = (int*)&ch ;
cout << cptr << endl;
We declare a character variable ch with data = ‘A’
&ch prints its data in statement cout << &ch << endl;
Then we declare a pointer to integer named cptr.
We use * to signify that this is a pointer variable.
We use typecasting to convert the (char *) pointer to (int *) so we don’t get an error.
When we print cptr using cout << cptr << endl statement , since the address of ch was stored in cptr , the address gets printed.
This print statement will give the same result as the previous print statement where we printed &ch as it is the address of ch only that we are storing in cptr.