Why won’t the following C code compile? It seems like it should just change the pointers’ address but it throws an error.
int x[10];
int y[10];
y=x;
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.
xandyare arrays, not pointers. In C, arrays can’t change size or location; only their contents can change. You can’t assign arrays directly.If you want a pointer to one of the arrays you can declare one like this.
If you need to assign an array you can create a struct that contains an array.
structs are assignable in C.