0

For my code I having an error as stated with arrays and am not sure as to how to fix it I have included some of my code

switch (level_of_play) {

case 1:

    size = 4;

    speed_of_play = 6;

    break;

There are multiple cases I have just included one. The error then arises

string answer_grid[size][size];/** answer array**/

string display_grid[size][size];/**display array**/

srand(time(NULL));

I tried to place the string size into the case but that will not work as my program uses display_gride in further parts outside of the cases. Please help with how I can fix this to allow still multiple choices of array size.

James
  • 1
  • 2
  • Also relevant: https://stackoverflow.com/questions/4029870/how-to-create-a-dynamic-array-of-integers – fabian Jul 23 '22 at 06:43
  • If you are using `string` then you should also know how to use `vector`. This is the solution to your problem. – john Jul 23 '22 at 07:05
  • `vector> answer_grid(size, vector(size));` – john Jul 23 '22 at 07:07
  • You are a life saver and thank you! The class I am hardly taught string so didn't even know about vector. – James Jul 23 '22 at 07:22

0 Answers0