#include <stdio.h>
int main(int argc, char **argv) {
// your code goes here
char *p;
p = "hello";
printf("%s",*&*&p);
return 0;
}
It give same output for p
, *&p
, *&*&p
. how is this possible?
#include <stdio.h>
int main(int argc, char **argv) {
// your code goes here
char *p;
p = "hello";
printf("%s",*&*&p);
return 0;
}
It give same output for p
, *&p
, *&*&p
. how is this possible?
p is the pointer pointing to string "hello". &p is address of p , So *&p will be the value at address of p which is again the pointer pointing to string "hello"
*
means give whatever is at this location in memory.
&
gives the memory address of this object.
Therefore:
p
is the address that the string hello
starts at.
*&p
means give me whatever is at the location of p (i.e. the address that hello
starts at).
*&*&p
means give me whatever is at the location that is at the location of p
So all of those just give you p
.