2 dimensional arrays passed to a function in c++

Posted by John Marcus on Stack Overflow See other posts from Stack Overflow or by John Marcus
Published on 2010-12-18T00:31:12Z Indexed on 2012/06/01 22:40 UTC
Read the original article Hit count: 165

I'm working on doing calculations in a two dimensional array

but keep getting a nasty error.

i call the function by :

if(checkArray(array))

and try to pass it in like this:

bool checkArray(double array[][10])  //or double *array[][10] to no avail  

the error is

error: cannot convert ‘double ()[(((unsigned int)(((int)n) + -0x00000000000000001)) + 1)]’ to ‘double’ for argument ‘1’ to ‘bool checkArray(double*)’

code snippet

//array declaration

int n = 10;
double array[n][n];

//function call to pass in array


   while(f != 25)
   {

        cout<<endl;
    cout<<endl;

        if(checkArray(array)) //this is the line of the error
         {
      cout<<"EXIT EXIT EXIT"<<endl;
        }

        f++;

    }

    //function declaration

       bool checkArray(double *array)//, double newArray[][10])
       {
            double length = sizeof(array);
            for(int i = 0; i < length; i++)
            for(int j = 0; j < length;j++)
            {
                double temp = array[i][j];
                    }
         }

© Stack Overflow or respective owner

Related posts about c++

Related posts about function