Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what will work and what won't.</p> <ol> <li><p>The passing of arrays will work fine . </p></li> <li><p>You will also need to enclose the <code>for</code> loop in the <code>switch</code> block with curly brackets <code>{..}</code>.</p></li> </ol> <p>Full code listing:</p> <pre><code>#include &lt;iostream&gt; using namespace std ; const int NUM_OF_ARRAYS = 8; int **arrays = new int*[NUM_OF_ARRAYS]; void fillArrays(int **arrays); int main(void) { arrays[0] = new int[128]; arrays[1] = new int[512]; arrays[2] = new int[2048]; arrays[3] = new int[8192]; arrays[4] = new int[32768]; arrays[5] = new int[131072]; arrays[6] = new int[524288]; arrays[7] = new int[2097152]; fillArrays(arrays); cout&lt;&lt;" \nPress any key to continue\n"; cin.ignore(); cin.get(); return 0; } void fillArrays(int **arrays) { const int NUM_OF_ARRAYS = 8; for(int i = 0;i &lt; NUM_OF_ARRAYS;i++) { switch(i) { case 0: { for(int j = 0;j &lt; 128;j++) { arrays[i][j] = 1 + rand() % 2000; cout&lt;&lt;arrays[i][j]&lt;&lt;"\n";} } break; case 1: { for(int j = 0;j &lt; 512;j++) arrays[i][j] = 1 + rand() % 5000; } break; case 2: { for(int j = 0;j &lt; 2048;j++) arrays[i][j] = 1 + rand() % 10000; } break; case 3: { for(int j = 0;j&lt; 8192;j++) arrays[i][j] = 1 + rand() % 30000; } break; case 4: { for(int j = 0;j &lt; 32768;j++) arrays[i][j] = 1 + rand() % 100000; } break; case 5: { for(int j = 0;j &lt; 131072;j++) arrays[i][j] = 1 + rand() % 200000; } break; case 6: { for(int j = 0;j &lt; 524288;j++) arrays[i][j] = 1 + rand() % 1000000; } break; case 7: { for(int j = 0;j &lt; 2097152;j++) arrays[i][j] = 1 + rand() % 30000000; } break; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload