+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

4/19/2019 9:11:53 AM

Suraj Dhenge

7 Answers

New Answer

+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 ".

+9

It's a bit like the person who lives at the address of the person who lives at the address p.

+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.

+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.

+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.

+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

0

Can someone help me ? I read 1000+ times this Q&As but i didn't get it.