Translate

Thursday, December 19, 2013

C C++ C#

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?

No comments:

Post a Comment

ग़ज़ल

rizw4nkh4n *ख़ुलूस-ए-दिल = purity of heart *एहतराम = आदर, सम्मान *मिज़ाजपुरसी = हाल-चाल पूछना *बाम = घर में सबसे ऊपर का कोठा और छत *इक़राम =...