I thought that in gcc, void * and char * are treated the same way when it comes to pointer arithmetic, i.e. void * "points" to a single byte in memory, so the following code
void *p;
p = malloc(sizeof(void));
printf("%p %p\n",p,p+1);
indeed returns 0x984a008 0x984a009
. Similarly, void ** points to a pointer, so an increment by one really means an increment by 4 bytes (on a 32 bit OS), i.e.
void **p;
p = (void **) malloc(sizeof(void *));
printf("%p %p\n",p,p+1);
returns 0x984a008 0x984a00c
. However, the following code confuses me
void **p, *p1;
p = (void **) malloc(sizeof(void *));
p1 = (void **) p;
printf("%p %p\n",p1,p1+1);
Since it returns again 0x984a008 0x984a009
. What is going on here?