I have the following code:
#include<stdio.h>
int main(void){
int array[5]={10,20,30,40,50};
int *p;
p=array;
printf("%p\n", array);
printf("%p\n", p);
printf("%p\n", &array[0]);
printf("%p\n", &p[0]);
printf("%p\n", &(*array));
return 0;
}
Compiling this code with GCC and printing the values of the addresses out with %p gives the following warnings:
01.c: In function ‘main’: 01.c:7:12: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=] printf("%p\n", array); ~^ ~~~~~ %ls 01.c:8:12: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=] printf("%p\n", p); ~^ ~ %ls 01.c:9:12: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=] printf("%p\n", &array[0]); ~^ ~~~~~~~~~ %ls 01.c:10:12: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=] printf("%p\n", &p[0]); ~^ ~~~~~ %ls 01.c:11:12: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=] printf("%p\n", &(*array)); ~^ ~~~~~~~~~ %ls ```
How can I solve them and why are they happening? Also, what is %ls?