As the answer in the second link explains that
For
printf
,p
conversion specifier requires avoid *
argument. If the argument is of a different type, the function call invokes undefined behavior. So if the argument ofp
is an object pointer type, the (void *
) cast is required.
That is, since your code snippet invokes undefined behavior, you can get anything, either expected or unexpected result. The result you are getting may also vary compiler to compiler. On my compiler (GCC 4.8.1) it is giving the result: