Or will the address a be equal to the integer that b references?
Or will something else happen?
Edit: Also, if double *a = 3.0, does a point to 3.0?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the code is
int *a = *b;then*bis a pointer to an integer (has to match the type ofa). That means thatbis a pointer to a pointer to an integer.awould then contain the address that*bis pointing to, not to the address thatbis pointing to.However, if the code is
int *a; *a = *b;then that’s different. In that case you are copying the object thatbis pointing to into the address thatais pointing to. The object has to be an integer, soawill point to a copy of the integer (so you could change*band*awill not change). By the way, Ifain uninitialised, that would be undefined behaviour (very likely a crash).