char strings[10][100], ** ptr = strings;
Someone can help with it? What isn't right with this part of code, isn't right that **strings == strings[0][0], and strings[0][0] is char? Sorry for my really bad english.
char strings[10][100], ** ptr = strings;
Someone can help with it? What isn't right with this part of code, isn't right that **strings == strings[0][0], and strings[0][0] is char? Sorry for my really bad english.
The compiler recognizes that strings
is an array of arrays and therefore suggests to declare the pointer accordingly:
char strings[10][100], (*ptr)[100] = strings;
As mentioned by David C. Rankin a conversion takes place in the initialization of ptr
. strings
is converted from an array of arrays of 100 chars to a pointer to an array of 100 chars pointing to the first element of this array of arrays. The conversion is specified here: C11 Standard - 6.3.2.1 Other Operands - Lvalues, arrays, and function designators(p3).
the warning:
Warning: initialization of ‘char **’ from incompatible pointer type ‘char (*)[100]’ [-Wincompatible-pointer-types]
8 | char strings[10][100], ** ptr = strings;
It says that: ptr & strings are different types so ptr[0][0¿ & string[0][0] are diffrents