[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

Passing arrays to functions

How can i pass a two dimesional array
(not a global variable) to a function from main().The array is an object to a class.
0
ab2
Asked:
ab2
  • 3
1 Solution
 
nietodCommented:
void function(char [10][20] TwoDArray)
{
}

int main()
{
   char Array[10][20];

   function(Array);
};

Let me know if you have any questions.
0
 
Louis020400Commented:
void MultiArrayparam1( int m[ 3 ][ 5 ]  )
{
//dimentions know at compile time
}

void MultiArrayparam2( int m[ ][ 5 ], int dim1 )
{
//pass first dime as an argument
}


void MultiArrayparam3( int * m, int dim1, int dim2 )
{
//pass both as arguments
}

void main()
{
    MultiArrayparam1( myArray );
    MultiArrayparam2( myArray,3);
    MultiArrayparam3( &myArray[0]      [0],3,5 );

}
0
 
AdihCommented:
//func receives an object by reference
void func(darray& darr);

void main()
{
//creating the object- 5,10 are
//parameters for the c`tor.
    darray d(5,10);
//sending the object to the function
    func(d);
}

0
 
nietodCommented:
So ab2, are you out there?
0
 
nietodCommented:
ab2, what is happening with this question?
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now