I wrote a program to understand a concept of pointer, where i declared an array of 5 integer pointers and then i tried to print the address of various indices of the array. But what I do not understand is that why is the difference between the consecutive address of indices of 8 bits and not of 4 bits in the output?
My code is:
#include<stdio.h>
void main()
{
int i;
int *b[5];
for(i = 0; i < 5; i++){
b[i] = (int *) malloc(10 * (sizeof(int)));}
printf(" b = %u \n\n",b);
printf(" (b+1) = %u \n\n", (b+1));
printf(" (b+2) = %u \n\n", (b+2));
printf(" *(b+2) = %u \n\n", *(b+2));
printf(" *(b+2)+3) = %u \n\n", *(b+2) + 3);
*(*(b+2) + 3) = 5;
printf(" b[2][3] = %u \n\n", b[2][3]);
}
The output is as follows
b = 79107440
(b+1) = 79107448
(b+2) = 79107456
*(b+2) = 3293532864
*(b+2)+3) = 3293532876
b[2][3] = 3293533008
Clearly the difference between (b+1) and b is of 8 bits.WHY?