"Roka" <> writes:
> Spidey wrote:
>> What kind of formating can be done with %p in printf
>
> To print out an address.
> eg.
>
> char *p = "abc";
> printf("The address of *abc* is %p\n",p);
> printf("The address of p is %p\n",&p);
>
>
> result may be:
> The address of *abc* is 0x804841c
> The address of p is 0xbffff474
"%p" expects a void* argument. Giving it a char* is ok (but poor
style IMHO); giving it char** is likely to work, but is strictly
speaking non-portable.
char *p = "abc";
printf("The address of *abc* is %p\n", (void*)p);
printf("The address of p is %p\n", (void*)&p);
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.