In BCB, I need to pass a two dimensional array to a function Ratio. I did this without pointers or reference. Could any body else tell me what I should revise if I want to use pointers or reference for input?

double Ratio(double a[3], double VA[3][3], int i)
{
        double bg;
        if (a[i] <= 0.0) bg = VA[0][i];
        else if (a[i] > 	VA[2][i]) bg = VARAT[1][i];
        else bg = (1.-a[i]/VA[2][i])*(VA[0][i]-VA[1][i])+VA[2][i];
        return bg;
}

In the main:

int main()
{
...
        Ratio(a1, VA1, n);
...
}

>>Could any body else tell me what I should revise if I want to use pointers or reference for input?

Nothing. Its already coded by reference because its not possible to pass an array any other way (pointers and references are essentially the same thing, although there are a couple minor differences).

If you really want to I suppose you code code it like this

double Ratio(double* a, double** VA, int i)

> double Ratio(double* a, double** VA, int i) Except that is no longer equivalent to double Ratio(double a[3], double VA[3][3], int i) The function will still compile with a ** pointer, but how you call the function changes.

To be the same as the OP's declaration, it would be double Ratio(double *a, double (*VA)[3], int i)

Thank both of you for help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.