Character value * and &

What do the symbols *and &in this code:

#include<stdio.h>
main()
{
  char *p;
  p="hello";
  printf("%s\n",*&*&p);
}

What does the operator do printfin the above program? In particular, what does it mean *&*&p?

+5
source share
2 answers

printfwill print a string "hello"because &- this is the operator addressOfthat will return the address of the pointer, followed by it, and *- this is the operator valueOfthat will return the value stored in the address of the pointer, followed by it.

So essentially the expression *&*&pwill read

valueOf(addressOf(valueOf(addressOf(p))))

which will return a string "hello"that is stored in the actual location.

Hope this helps you!

+4
source

It:

*&*&

, . p, * char*. ...

:

*(&(*(&p)))

main , int .

+9

All Articles