I have the following source:
#include <iostream>
using namespace std;
void main(int j)
{
char arr[10][10];
char** ptr;
ptr = arr;
}
when I compile it using VS2010 I get this error:
error : a value of type "char (*)[10]" cannot be assigned to an entity of type "char **"
I thought arrays in c++ were just pointers. So a char[][] could also be char**. What am I doing wrong?
The types
char[10][10]andchar**andchar (*)[10]are all different types. However, the first one cannot convert into the second one, it can convert into the third one.So try this:
It will work, because as I said object of type
char[10][10]can convert into an object of typechar (*)[10]. They’re compatible types.