Possible Duplicate:
Is it possible to find out the variable name, the pointer pointing to?
Is it Possible to get the name of array the pointer pointing too?
example:
char name[20];
char *p=name
int door_no;
int *q= & door_no
In the above example we are giving the base address of the array with the array name and pointer q pointing to door_no but what if, I have to know the name of the variable the array pointing too? what is the variable name pointer q is pointing too ? Is it possible I made tries and I came to a conclusion no its not possible but still Iam trying to get the solution. and what you think guys ? Is there any way to make it possible?
Short answer: No.
Long Answer:
In C variable names do not exist after compilation (everything is converted to either memory locations or register locations).
The compiler may potentially assign multiple variables to the same memory/register location if their lifespans of the two objects do not overlap. Thus the concept of variable names at runtime has no meaning (in the context of C)