I\'m trying to print out the value of argv
at this point in my code, but when I try to compile it, I get
warning: format ‘%p’ expects argument of type ‘vo
Well, not any pointer (type).
According to C11
, chapter §7.21.6.1, for the %p
conversion specifier,
p
The argument shall be a pointer to
void
. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner.
So, the argument must be of type void *
(or, a char*
, given they have the same alignment requirements). Any other type of pointers, must be converted through an explicit cast, as there is no default argument promotion for pointers.
Something like
printf("%s%p", "argv = ", (void *)argv);
should do.