Thursday, July 30, 2009

Please explain the code below?

returning arrays from functions 7/28/2006 4:36 AM


cAN ANY BODY EXPLAINME THESE METHOD FOR RETURNING ARRAY FROM FUNCTIONS


-a POINTER TO AN INTEGER


-A POINTER TO ZEROTH 1-D ARRAY


-a POINTER TO 2-D ARRAY





//CODE FOR DECLARATION


#define COL 4


#define ROW 3


main(){


//declaration


int *a;


int *fun1();





int (*b)[COl];


int (*fun2())[COl];





int (*c)[ROW][COL];


int (*fun3())[ROW][COL];





//function calling


a = fun1();


//Display the array()//code not writing here to display


b = fun2();


//Display the array()//code not writing here to display


c = fun3();


//Display the array()//code not writing here to display


}





int *fun1()


{


static int a[ROW][COL] = {


1,2,3,4,


5,6,7,8,


9,0,1,6


};


display array "a"





return (int *)a;//%26lt;--what is done here


}





int (*fun2())[COL]//%26lt;----this declaration is little confusing 4 me


{





static int b[ROW][COL] = {


1,2,3,4,


5,6,7,8,


9,0,1,6


};


display array "b"





return b;//%26lt;--what is done here


}





int (*fun3())[ROW][COL]


{


static int c[ROW][COL] = {


1,2,3,4,


5,6,7,8,


9,0,1,6


};


display array "c"





return (int (*)[ROW][COL])c;//%26lt;--what is done here


}


plz explain howw this declaration works

Please explain the code below?
"WE WILL DESTROY YOUR PLANET"


Call the pentagon, quick!!


No comments:

Post a Comment