I tried to send address of array element to the function
Code:
#include <stdio.h>
void fun(int *pointer)
{
int i;
for ( i = 0; i < 8; i++)
printf("\n %p %d \n", pointer, i);
}
int main()
{
int i;
int array[] = {1, 2, 3, 4, 5, 6, 7, 8};
for( i = 0; i < 8; i++)
{
printf("\n address of array[%d] %p", i, &array[i]);
}
for( i = 0; i < 8; i++)
{
printf("\n content of array[%d]: %d", i, array[i] );
}
fun(array);
return 0;
}
address of array[0] 0061FF0C
address of array[1] 0061FF10
address of array[2] 0061FF14
address of array[3] 0061FF18
address of array[4] 0061FF1C
address of array[5] 0061FF20
address of array[6] 0061FF24
address of array[7] 0061FF28
content of array[0]: 1
content of array[1]: 2
content of array[2]: 3
content of array[3]: 4
content of array[4]: 5
content of array[5]: 6
content of array[6]: 7
content of array[7]: 8
0061FF0C 0
0061FF0C 1
0061FF0C 2
0061FF0C 3
0061FF0C 4
0061FF0C 5
0061FF0C 6
0061FF0C 7
Pointer hold the address of other variable
content of pointer and address of array would be same
so pointer [i] should be same as &array[i] ?
From the output of code it does't seem to correct ?