+ 8

what's the meaning of printf("%c",*&*p); ,it is giving same output as below statement in code. Anyone know whats the *&*p doing?

https://code.sololearn.com/cCQTKoWIoGTo/?ref=app

19th Apr 2019, 9:11 AM
Suraj Dhenge
Suraj Dhenge - avatar
7 RĂ©ponses
+ 1
Lwin Moe " & " give address of variable.. " *& " gives the value of variable.. This is the conclusion. " *&" will point to value of pointer .. that is the address in it.. and this address will point towards the memory location. " & " will give the address of pointer. Without using & and *&.. pointer can be directly used to point at any memory location by " *pointer " (pointer is the name of pointer variable) and to get the address of pointer, simply use " pointer ".
20th Apr 2019, 5:32 PM
Suraj Dhenge
Suraj Dhenge - avatar
+ 9
It's a bit like the person who lives at the address of the person who lives at the address p.
20th Apr 2019, 1:44 AM
Sonic
Sonic - avatar
+ 7
"*&*p" basically means - get the value the pointer *p is pointing to located at the memory address of *p. Without asterisk it would display the actual address of p "&*p" (you need to change the format specifier from char to see it). Yes, it seems to be doing the same job as *p. I'm new to C, would like to know the opinion of more experienced people as well.
19th Apr 2019, 10:16 AM
{ 𝄋 ℒ 𝄋 }
{ 𝄋 ℒ 𝄋 } - avatar
+ 5
{ 𝄋 ℒ 𝄋 } I think.. As any variable is assigned an address.. "&" is use to give address to any variable, "*&" is used to give the value of variable.. i.e. getting the value inside the location (assigned to variable) of variable... try printing a variable using "*&".. we get the value of variable.
19th Apr 2019, 10:47 AM
Suraj Dhenge
Suraj Dhenge - avatar
+ 4
'*' goes to the value stored in the address and '&' goes to the address of p. So what you're basically doing is you're accessing what's stored in p's address and then the address itself and back to what's stored in it. The address of p is the address of the first character in the string.
19th Apr 2019, 3:09 PM
Alexander Sheremet
Alexander Sheremet - avatar
+ 1
Suraj Dhenge Thank you i get it . I confuse that using both ''*&" . I noted that "*" for value , "&" for address. I have never seen before like that. So i confused
20th Apr 2019, 5:58 PM
Lwin Moe
Lwin Moe - avatar
0
Can someone help me ? I read 1000+ times this Q&As but i didn't get it.
20th Apr 2019, 5:23 PM
Lwin Moe
Lwin Moe - avatar