Returning Array from Function
can any one please explain me this code :-
Code:
#include<stdio.h>
#include<conio.h>
#define ROW 3
#define COL 4
int main()
{
int i,j;
int(*c)[ROW][COL];
int (*fun3())[ROW][COL];
c=fun3();
printf("Array c[][] in main():\n");
for(i=0;i<ROW;i++)
{
for(j=0;j<COL;j++)
printf("%d\n",(*c)[i][j]);
printf("\n");
}
_getch();
return 0;
}
int (*fun3())[ROW][COL]
{
static int c[ROW][COL]={
6,3,9,1,
2,1,5,7,
4,1,1,6
};
int i,j;
printf("Aray c[][] in fun3():\n");
for(i=0;i<ROW;i++)
{
for(j=0;j<COL;j++)
{
printf("%d",c[i][j]);
printf("\n");
}
}
return (int(*)[ROW][COL])c;
}
i am not getting
1.
Code:
int (*fun3())[ROW][COL];
2. working of this :-
Code:
for(i=0;i<ROW;i++)
{
for(j=0;j<COL;j++)
printf("%d\n",(*c)[i][j]);
3.
Code:
return (int(*)[ROW][COL])c;
please explain and suggest some site/blog/book where i can read on this