I am making an error somewhere at the last line. It is not showing the correct value at the address.
/* an array with 5 elements */
double balance[5] = {1000.0, 2.0, 3.4, 17.0, 50.0};
double backup[5];
double *p;
double address;
int i = 0;
memcpy(&backup, &balance, sizeof(balance));
p = backup;
/* output each array element's value */
printf( "Array values using pointer\n");
for ( i = 0; i < 5; i++ )
{
//printf("*(p + %d) : %f\n", i, *(p + i) );
printf("&p[%d] : %f\n", i, p[i]);
printf("&p[%d] : address: %p\n", i, (void*)(&p+i));
}
int offset = 4;
printf("Contents of &p[%d] : address: %x is %f\n", offset, ((&p)+(offset)), p[offset]);
double* newPointer;
newPointer = ((&p)+(offset));
printf("The content again: %f at address: %x\n", *(newPointer), newPointer);
// output is incorrect
The content again: 0.000000 at address: 28feec