Hi
I wrote this code for fun, just wanted to see what will happen! I declared o pinter that holds its own address. But there is something wrong!
Code:
#include <stdio.h>
int main()
{
char foo='f';
char *pc;
char **ppc;
pc=&foo;
ppc=&pc;
printf("pc -> %p\n",pc);
printf("&pc -> %p\n",&pc);
printf("ppc -> %p\n",ppc);
pc=&pc;
//ppc=&pc;
//pc=*ppc;
printf("pc -> %p\n",pc);
return 0;
}
The code is compiled with "incompatible assignment" warning. But it works!
But, i think the right way of doing this is to declare a **char and hold the address of *char in **char. But this does not work! When I uncomment the commented lines and leave out the pc = &pc; line, the code does not work!