0

How can I properly return a 2d array from a function? When I cout the values to test, it works, but when I try to return it, the compiler gives me an error saying that the function types do not match.

What is the correct way to prototype a function that will return a 2d array??

int** arytest(int*, int); // prototype

Here is what I have...

    // an ampty array
    int array2d[2][10];

    // pointers to parts
    int *array1 = array2d[0];
    int *array2 = array2d[1];

    // fill "arrays"
    for (i = 0; i < 10; ++i) {
        array1[i] = uncommons[i];
    }
    for (i = 0; i<10; ++i) {
        array2[i] = totals[i];
    }
    for (i = 0; i < 10; ++i) {
        if (array2d[0][i] == 1)
            cout << i << " occurs " << array2d[1][i]; // testing

    }

    return array2d;
}
Ryu
  • 45
  • 4

0 Answers0