In the following code:
int main()
{
char names[2][11] = {"Manchester","Party"};
char (*jk)[11];
jk = names; // LINE 1
char gaming[10] = {"Jetking"};
char (*po)[10];
po = &gaming; // LINE 2
cout<<"PO is "<<*po;
Line 2 requires me to put & in front of gaming, while Line 1 doesnt. The error it gives for Line 2 when I dont put & is, “error: cannot convert ‘char [10]’ to ‘char (*)[10]’ in assignment” ? I didnt quite understand this part. Since “char (*po)[10];” can be interpreted as a pointer to an array of 10 characters.
In the assignment
the array
namesof typechar[2][11]is converted to a pointer to its first element, thus it decays into achar (*)[11].gaming, however is converted into achar*in most contexts, and thatchar*is incompatible with the type thatpohas,char (*)[10], so that assignment is invalid. If you take the address ofgaming, you get exactly the requiredchar (*)[10].