printing pointers c
i perplexing know something pointers, i wrote code:
#include <stdio.h>
int main(void)
{
bake s[] = "asd";
bake **p = &s;
printf("the value s is: %p\n", s);
printf("the instruction s is: %p\n", &s);
printf("the value p is: %p\n", p);
printf("the instruction p is: %p\n", &p);
printf("the instruction s[0] is: %p\n", &s[0]);
printf("the instruction s[1] is: %p\n", &s[1]);
printf("the instruction s[2] is: %p\n", &s[2]);
relapse 0;
}
when compiling gcc i warnings:
$ gcc main.c -o main-bin -ansi -pedantic -wall -lm
main.c: duty main:
main.c:6: warning: initialization proud pointer type
main.c:9: warning: format %p expects form void *, nonetheless justification 2 form char (*)[4]
main.c:11: warning: format %p expects form void *, nonetheless justification 2 form char **
main.c:12: warning: format %p expects form void *, nonetheless justification 2 form char ***
(the flags gcc since i contingency c89)
why proud forms pointer? isn't name an array pointer it's initial element? s pointer 'a', &s contingency char **, no?
and since i warnings? i have ban pointers (void *) method imitation them?
and controlling i something this:
$ ./main-bin
the value s is: 0xbfb7c860
the instruction s is: 0xbfb7c860
the value p is: 0xbfb7c860
the instruction p is: 0xbfb7c85c
the instruction s[0] is: 0xbfb7c860
the instruction s[1] is: 0xbfb7c861
the instruction s[2] is: 0xbfb7c862
how value s it's instruction (and impetus value p) same?
Comments
Post a Comment