188k views
4 votes
Dеclarе and allocatе mеmory (on thе hеap) for a two-dimеnsional array of strings namеd carMakеs with 20 rows, еach with 6 columns

User Putna
by
5.5k points

1 Answer

4 votes

Answer:

string ** carMakes=new string*[20];

for(int i=0;i<20;i++)

{

carMakes[i]=new string[6];

}

Step-by-step explanation:

The above written piece of code is in C++ and it will declare and allocate memory on the heap for a 2-D array of strings with the number of rows 20 and number of columns 6 with name of the array carMakes.

To declare a 2-D array in C++ we use new keyword.

User Shmack
by
4.8k points