In the following code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
double *p= (double *)malloc(sizeof(double)*5);
double *s= (double *)malloc(sizeof(double));
printf("Enter first value: "); scanf("%lf",p);
printf("\nEnter 2nd value: "); scanf("%lf",p+1);
printf("\nEnter 3rd value: "); scanf("%lf",p+2);
printf("\n\ntable is:\n");
printf("1st value %f\taddress: %p\n",*p,p);
printf("2nd value %f\taddress: %p\n",*(p+1),(p+1));
printf("3rd value %f\taddress: %p\n",*(p+2),(p+2));
printf("\n\n\nvalue %f\taddress: %p\n",*s,s);
return 0;}
Now suppose that the pointer p contains the hex value 00BD0D50. But the address obtained from when i use p+1 , will give the hex value. 00BD0D58. Why there is this gap of 00000008 between these values even when only 1 is added to p's value ?
I tried using %d in place of %p to output pointer's value but still it had a difference of 8.
And if there is some reason behind it, is there any other way to access a value at address lying between this gap of 00000008 bytes? ( for example in above case, is there any way to access value at 00BD0D51 ?)