#include <stdio.h>
int main(void) {
int x = 5;
int y = 10;
int* px = &x;
int* py = &y;
printf("the adress of %d is %p.\n",x,px);
printf("the adress of %d is %p.\n",y,py);
*px = 8;//change the value at the adress of px
*py = 18;
//what happens if instead of *px = 8, just x = 8?
x = 99;
printf("the adress of %d is %p.\n",x,px);
printf("the adress of %d is %p.\n",y,py);
//so It did change, what's the point of using *px when changing the value?
return 0;
}
Hello, I started learning C in school, and I bump into a difficulty which could be extremely simple, but at this point I do not know about it. I am trying to change the value of x, and I used the method *px = 8 first to change it. but right after that I used x = 99, and it changed too, so I do not know what is the difference between them. I appreciate any feedback, thank you!