I believe value of pointer should be equal to address of array element
Code:
#include<stdio.h>
int main (void)
{
int i;
int *pointer;
int array[5] = {10, 20, 30, 40, 50};
pointer = &array;
for (i = 0; i <5; i++)
{
printf("Memory Allocation %p : [%d] = %d \n", &array[i], i, array[i] );
}
for (i = 0; i <5; i++)
{
printf("%p : %d \n", (pointer++), (*pointer++));
}
printf("size of array : %d \n", sizeof(array));
return 0;
}
Memory Allocation 0061FF14 : [0] = 10
Memory Allocation 0061FF18 : [1] = 20
Memory Allocation 0061FF1C : [2] = 30
Memory Allocation 0061FF20 : [3] = 40
Memory Allocation 0061FF24 : [4] = 50
0061FF18 : 10
0061FF20 : 30
0061FF28 : 50
0061FF30 : 3
0061FF38 : 2404352
size of array : 20
address of array should be same as the pointer value
In my program I am not getting output as I want, result show I am doing mistake. What's wrong with code