Can a pointer ever point to itself?

Posted by eSKay on Stack Overflow See other posts from Stack Overflow or by eSKay
Published on 2010-03-28T06:32:33Z Indexed on 2010/03/28 6:33 UTC
Read the original article Hit count: 217

Filed under:
|
|

This question was mentioned here.

My doubt is: If a pointer variable has the same address as its value, is it really pointing to itself?

For example - in the following piece of code, is a a pointer to itself?

#include<stdio.h>

int main(){
   int* a;
   int b = (int)&a;
   a = b;
   printf("address of a = %d\n", &a);
   printf("  value of a = %d\n", a);
}

If a is not a pointer to itself, then the same question poses again: Can a pointer point to itself?
Also, how is a self pointing pointer useful?

© Stack Overflow or respective owner

Related posts about c

    Related posts about pointers