2048(Recursion Problem)

char spellings[ ] = {“zero”,“one”,“two”,“three”,“four”,“five”,“six”,"seven
",“eight”,“nine”};

if we do cout<<spellings [8]; we are getting eight.i am not able to understand how we are able to access 2d array by using one paratheses?

@dare_devil_007 We can do that. There is no issue. spellings[8] means that spellings[8][all columns]
This will consider all columns at row 8 means it will print all the characters at 8th row.

but when we arw initialising the array 10 is conidered to be columns right? but how we are able to access?

char spellings[ ][10] = {“zero”,“one”,“two”,“three”,“four”,“five”,“six”,"seven
",“eight”,“nine”};
sorry this was the synatx.

In char spellings[ ][10] , 10 means that the maximum length of each string is 10. No of string is not initialized here. spellings[8] means that you are accessing the 8th string.

1 Like