santiago at mr-r.net
Fri Sep 22 16:15:45 MDT 2006
On Sep 22, 2006, at 2:08 PM, Dave Smith wrote:
> Russel Caldwell wrote:
>> Sorry, I guess this is a bit off topic but does anybody know if
>> there is a
>> way of obtaining the address where a character array is pointing
>> to in C++?
> The pointer value *is* the address. For example:
> char *foo = ....
> printf( "The address is %p\n", foo );
> You do not need to use the & operator.
It depends on what you mean by "character array". If you are talking
about a variable declared like so:
Then to get the address, you would do the following:
print("The address is %p\n", (&myarray));
If you are talking about a variable declared like:
char *myarray = new char;
Then the address is stored in 'myarray', and de-referencing 'myarray'
will give you the actual contents of the string.
More information about the PLUG