-
matrix
Hi, I have a few questions about this matrix "table"
I can't find any wrong in it
but errors keeps appear :(
C2057 expected constant expression
C2466 cannot allocate an array of constant size 0
C2087: 'table' : missing subscript
C2133: 'table' : unknown size
here's the code
thanks for helping :p
Code:
int lcs(string str1, string str2, string & sequence) {
int rows=str1.length() + 1, cols=str2.length() + 1, position, seqLength;
int table[rows][cols];
int i, j;
......
int main() {
string inp, first, second, outp;
int seqlen;
getline(cin, inp);
first = stripBlanks(inp);
getline(cin, inp);
second = stripBlanks(inp);
seqlen = lcs(first, second, outp);
......
-
Seems that rows and cols are no constants.
Kurt
-
You can not initialize arrays (matrix is multiple arrays) with non-constant variables (that is, the program can not decide at run-time).
However, if you want to be able for the program to decide the size of the arrays you can use pointers.