black hole sun
New member
Hi guys. I'm writng a simple program for my C++ class to print a magic square. To do this I need a mutlidimensional array, but I can't let the user type in the array dimensions without the compiler giving me crap about it. It will only let me use literal numbers as the "column" value in my multidimensional array, like so:
void fillMagicSquare(int [][3]);
It disallows, for example, this;
void fillMagicSquare(int [][num]); // error
...
cout << "Give me the dimension:";
cin >> num;
fillMagicSquare(ar[num][num]);
How can I work around this? I guess I could settle for making the array a predefined size but that's kinda lame.
void fillMagicSquare(int [][3]);
It disallows, for example, this;
void fillMagicSquare(int [][num]); // error
...
cout << "Give me the dimension:";
cin >> num;
fillMagicSquare(ar[num][num]);
How can I work around this? I guess I could settle for making the array a predefined size but that's kinda lame.
Last edited: