Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:21:35+00:00 2026-06-13T12:21:35+00:00

Possible Duplicate: passing 2d arrays I have a question in my codes. Can anyone

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:21:36+00:00Added an answer on June 13, 2026 at 12:21 pm

    Here is your problem:

    char path[Slength][Tlength];
    int common[Slength][Tlength];
    

    (where Slength and Tlength are non-constant expressions)

    Variable-length arrays are illegal. The C++ standard requires constant integral expressions for array bounds in declarations (in a new[] expression, the outermost bound can be variable).

    Note to voters: The OP marked his question as C++, someone else changed the tags, no idea what compiler is actually in use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is Java pass by reference? I have a question about passing by
Possible Duplicate: Passing a Int value to another class I have been trying to
Possible Duplicate: Xcode: Storyboard Tabbed Application Passing Data Back and Forth Basically I have
Possible Duplicate: How do I use arrays in C++? I have the following C
Possible Duplicate: Why passing &error instead of error in Cocoa programming? I have a
Possible Duplicate: PHP passing parameters via URL I know that if you have a
Possible Duplicate: MySQL query using an array Passing an array to mysql I have
Possible Duplicate: passing a pointer by reference in c++ I have a function that
Possible Duplicate: Passing multidimensional arrays as function arguments in C I'm trying to use
Possible Duplicate: passing in object by ref With the code below, the output would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.