I came across this very strange thing in this code.
#include <stdio.h>
int main()
{
float d = 12.432;
float *pd = &d;
printf("Value of d is %f\n", *pd);
printf("Address of d is %p\n", pd);
printf("Address of d+1 is %p\n", (pd + 1));
printf("Value at d+1 is %f\n", *(pd + 1));
int c = 1;
int *yh = &c;
printf("Value of c is %d\n", *yh);
printf("Address of c is %p\n", yh);
printf("Address of c+1 is %p\n", (yh + 1));
printf("Value at c+1 is %d\n", *(yh + 1));
return 0;
}
When I run this snippet in my machine the addresses of d+1
and c
come out to be the
same
When I run on repl.it or some online compiler, I get different addresses as it should give.
What is the issue?