There is an error of incompatible types because you assign arrays of strings (char * type in C) to arrays of pointers to ints (for example, int *x[] ). The error message given by the compiler is a bit confusing because C does a lot backstage to try to convert variables from one type to another.
Since characters are represented internally as numbers (letters correspond to their ASCII values), C can convert characters to ints, so it tries to treat the variables x and y as arrays of pointers to characters instead of ints, therefore, char *[3] . He sees {"foo", "bar", "baz"} as a char ** type, because strings are a char * type and arrays are essentially stored as pointers in C, so this is a pointer to char * or char ** .
While this is not completely related to your question, I also wonder what you are trying to do with x = y; As written, this will make x point to the same array as y, leaving the array x used to indicate inaccessibility. To check if two variables are equal in C, you should use the == operator. Testing equality is not so simple for arrays or strings, but it is completely beyond the scope of this question.
gmoomau
source share