char** is not equivalent to char[][]. Also, dimensions of an array must be constants. Even though some compilers allow variables, this is not standard c++.
See http://www.cplusplus.com/forum/articles/17108/
Here's a quick example of using a vector similar to how you were trying to use an array, I had to take a bit of a crash course in the vector class but it works:
#include <vector>
#include <iostream>
usingnamespace std;
void fillVector(int height, int width, char fill, vector<vector<char> > &mdVector)
{
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
mdVector[row][col] = fill;
}
}
}
void printVector(int height, int width, vector<vector<char> > &mdVector)
{
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
cout << mdVector[row][col];
}
cout << endl;
}
}
int main()
{
int height, width;
char fill;
cin >> height;
cin >> width;
cin >> fill;
vector<vector<char> > mdVector(height, vector<char> (width));
fillVector(height, width, fill, mdVector);
printVector(height, width, mdVector);
return 0;
}
It sets up a vector to emulate a 2D array, with line 37 taking place of array[x][y]; and then passes it to the functions by reference. You can index an element in a vector like you would an array. This is probably rather lacking in way of explaining how it works, but I figured I'd put togethor some working code using a vector to show you an alternative to an array (while learning about vectors myself at the same time). xD