Possible Duplicate:
passing 2d arrays
I have a question in my codes. Can anyone help me?
void print(char S[], char * * path, int i, int j) {
if (i == 0 || j == 0) return;
if (path[i][j] == 'c') {
print(S, path, i - 1, j - 1);
cout << S[i];
}
else if (path[i][j] == 'u') print(S, path, i - 1, j);
else print(S, path, i, j - 1);
}
int LongestCommonSubsequence(char S[], char T[]) {
int Slength = strlen(S);
int Tlength = strlen(T); /* Starting the index from 1 for our convinience (avoids handling special cases for negative indices) */
int i, j;
char path[Slength][Tlength];
int common[Slength][Tlength];
for (i = 0; i <= Tlength; i++) {
common[0][i] = 0;
} /*common[i][0]=0, for all i because there are no characters from string T*/
for (i = 0; i <= Slength; i++) {
common[i][0] = 0;
}
for (i = 1; i <= Slength; i++) {
for (j = 1; j <= Tlength; j++) {
if (S[i] == T[j]) {
common[i][j] = common[i - 1][j - 1] + 1;
path[i][j] = 'c';
}
else if (common[i - 1][j] >= common[i][j - 1]) {
common[i][j] = common[i - 1][j];
path[i][j] = 'u';
}
else {
common[i][j] = common[i][j - 1];
path[i][j] = 'l';
}
}
}
print(S, path, Slength, Tlength); // it gives an Error!!!!
return common[Slength][Tlength];
}
My error is in:
print(S,path,Slength,Tlength);
And It gives:
cannot convert ``char ()[((unsigned int)((int)Tlength))]
' to \``char**
' for argument `2' to ``void print(char, char**, int, int)'`
What should I do?