Well, this is not really a 2D array. It's more easy to consider it as a one dimension array of strings.
int main() {
int i;
char mostRecommended[3][50] = {"Star 4", "Time 5", "Wind 3"};
for(i = 0; i < 3; i++) {
printf("%s", mostRecommended[i]);
}
return 0;
}
Regarding the original code: mostRecommended[i][j]
type is char
which is a kind of int
. Therefore printf("%s"
which expect a char *
complain that the type is not the expected one.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…