Why does the following program give a 'conversion' : cannot convert from int[1][1] to int** error? I am compiling with VS2008 under Windows 7.
int main(){
int a[1][1] = {0};
int **p = a;
}
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.
You can only convert arrays to pointers one time. The “pointers == arrays” abstraction breaks from the second level onwards.
You can do
But it becomes clear you cannot convert multidimentional arrays to pointers-to-pointers if you see the memory layout in each case:
In the pointer-to-pointer approach the rows are not necessarily contiguous and there needs to be an extra array for the spine that points to the individual rows.