0

If I have these two arrays:

char * A[] = {"One", "Two", "Three","Four"};
char B[][10] = {"Five", "Six", "Seven", "Eight"};

and I try to do the following:

B[0] = A[0];

the compiler will give me the following error: incompatible types when assigning to type ‘char[10]’ from type ‘char *’

but if I do the opposite:

A[0] = B[0];

there is no error. I'd appreciate any help, thanks.

Leo
  • 11
  • 2

1 Answers1

-1

Arrays and pointers are different types: arrays are slightly less flexible, since the array name always point at the first element and can't be assigned a new value. That's why one operation is valid and the other isn't

papagaga
  • 1,108
  • 8
  • 14