I am not new to programming but I am new to C++. I have followed the directions of other sites of how to pass a two-dimensional array to a function. I am getting a confusing error. Please note that I have been working on this issue for two evenings. I tried to solve the problem myself before posting. I am also aware of the syntax of passing an array with the width defined. I am wanting to write a general use function and I don't want to be locked into any specific size.

Thank you in advance.

Here is my code:


#include <iostream>

using namespace std;

void initialize2DCharArray(char** array, int height, int width, char initChar);

void initialize2DCharArray(char** array, int height, int width, char initChar)
{
for(int colCount=0;colCount < height; colCount++)
{
for(int rowCount=0;rowCount < width; rowCount++)
{
array[rowCount][colCount] = initChar;
}
}
}

void main()
{
char c[3][3];

initialize2DCharArray(c, 3, 3, 'A');
}


Here is the error:

error C2664: 'initialize2DCharArray' : cannot convert parameter 1 from 'char [3][3]' to 'char **'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast