This is a discussion on matrix within the C++ Programming forums, part of the General Programming Boards category; Hi, I have a few questions about this matrix "table" I can't find any wrong in it but errors keeps ...

  1. #1
    Registered User
    Join Date
    Oct 2005


    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

    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);

  2. #2
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Seems that rows and cols are no constants.

  3. #3
    ^ Read Backwards^
    Join Date
    Sep 2005
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 02:30 PM
  2. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 05:57 PM
  3. Gauss-Jordan Matrix Inversion in C++
    By Max_Power82 in forum C++ Programming
    Replies: 3
    Last Post: 12-03-2006, 08:31 PM
  4. Matrix and vector operations on computers
    By DavidP in forum A Brief History of
    Replies: 11
    Last Post: 05-11-2004, 07:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21