I tried to print an unsigned int*
in C. I used %X
but the compiler said:
" format
%x
expects argument of typeunsigned int
, but argument 3 has typeunsigned int*
".
I also used "%u"
but I got the same error again.
Can anybody help me?
If you want to print a pointer, you need to use %p
format specifier and cast the argument to void *
. Something like
printf ("%p", (void *)x);
where x
is of type unsigned int*
.
However, if you want to print the value stored at x
, you need to dereference that, like
printf ("%u", *x);