of course the pointers in the structs point to the same thing. That is because you do a shallow copy. If you want the two char pointers inside the structs point to diffrent strings you need to do a deep copy ( copy the content pointed by the pointer in a and make the pointer in b point to the new content ).
>>now whatever I change in the pointer of a, also gets changed in b. So they both are pointing to the same thing, is there anyway I can get the address of to what they are pointing ?
From what i have understood, i would like to say the following :
A pointer actually stores an address of the variable it points to. So you may just retrieve the address of the variable (a character variable in your case) from the pointer value.
Say the pointer is char* ptr. Then ptr gives the address of to what it points to.
If i have misunderstood your question, however, you may poke me. :)
>i mean the variable name to which it is pointing ?? is it possible ?
It's possible, but not without some extra manual framework. But my question to you is, what if the pointer isn't pointing to the address of a variable? For example:
char *p = new char;
There's no variable involved here, the address refers to anonymous dynamically allocated memory.
>is there anyway I can get the address of to what they are pointing ?
The value of a pointer is the address that it points to.