I made a very simple program to print the address of two variables.
#include
int main()
{
int a,b;
printf(\"%u\\n%u\",&a,&b);
The correct format specifier for printing an address (pointer) is %p
and you need to cast the argument to void *
.
Hence, the warning is valid and should be there.
But, when I compiled with GCC-5.x, it gave no warnings
In case of gcc
, please include -Wall
Note compiler option and try to compile. I believe it will throw the (same) warning we're expecting.
Note: Actually, -Wformat
, which checks for the type of supplied argument to printf()
and scanf()
family calls. -Wall
enables -Wformat
.