#include<stdio.h>
int main()
{
char str[25] = "Hello World";
printf("%s\n", &str+2);
printf("%p\n",&str);
printf("%p\n",&str+2);
return 0;
}
The program above flashes an error for line 6 saying:
warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[25]’ [-Wformat=]
I wonder what's the difference between these two. And the output always shows two addresses having a difference of 32 bytes. I was expecting an output with a difference of 2 as I'm trying to print the address of str
and address of str
+2. Can you explain?