Friday, August 19, 2011

Passing 2D array to a function

                 2D arrays are passed to a function in the same manner as that of one dimensional array. To pass a 2D array to a function, array name must be specified without any bracket, as an actual argument within the function call. The corresponding formal argument in the called function must be declared as an array with two size specification. The first size specialization may or may not be specified in the formal declaration, but empty pair of braces must be written with an array name. The other size specification needs to be specified.
E.g.
Int main()
{
Int x[10] [5];
……………………                       
Void func1 (int x[ ] [5], int , int);          //function declaration
……………………….                              
Func1 (x, 10, 5);      //function call         
}                                                             
Void func1 (int x[ ] [5], int n)        //no semi colon
{                                               
……………
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More