I have the following code:
int *pa;
int a[3] = {1, 2, 3};
Why pa = a is ok, but a = pa is not allowed?
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.
The main difference is that type of
ais still an array but it just decays into a pointer when you dopa=a;.pawill now point to the first element of the array not the entire array itself. When you doa=pait doesnot make any sense as you are trying point a datatype which is holding 3 integers to a type which can point only to a single integer.