My question 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
", &a);
printf(" value of a = %d
", 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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…