What is the difference between the following two assignments?
int main()
{
int a=10;
int* p= &a;
int* q = (int*)p; <-------------------------
int* r = (int*)&p; <-------------------------
}
I am very much confused about the behavior of the two declarations.
When should i use one over the other?
Is correct, albeit too verbose.
int* q = pis sufficient. Bothqandpareintpointers.Is incorrect (logically, although it might compile), since
&pis anint**butris aint*. I can’t think of a situation where you’d want this.