Initialization of a pointer in C-a question
hi
I came accross an example where pointer is initialised directly from integer:
int x=1;
int *px=x; //notice it doesn't use &x
printf("%d",(int)px);
What is happening here ? How can pointer get address from x ?
And if you can get value of x by just casting poinetr to int ,that would mean that px saved a value of an integer and not its address .
And what is the benefit of doing it like that ? Is assigment any faster ?
thank you
bye
|