char spellings[][10] = {“zero”,“one”,“two”,“three”,“four”,“five”,“six”,“seven”,“eight”,“nine”};
cout << spellings[6] <<" ";
How is this stored in memory and what does [ ] means ? How is it accessed like a 1d array?
@amitqy
While storing a 2D array, you need to specify the column width which is 10 here while you can ignore the row number which is calculated while initialisation and is equal to the number of elements in array
It this case it is stored as a character 2D array with size = row * column * sizeof(char)
row = 10
column = 10
So 100 * sizeof(char)
all the strings are stored in Ist row of this matrix ?
@amitqy
So there are 10 rows, 1 row for each word
Each row has 10 columns to store characters
So there are 10 rows, 1 row for each word
Each row has 10 columns to store characters
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.