Vamsi,
>
> Hello Vijay,
>
> My name is Vamsi working for Satyam here in Bangalore.
>
> Recently I have seen ur site in Yahoo groups.
>
> The solutions whatever you have given for C Faqs is amazing.
>
> I have come across one typedef in that solutions which is
> type defining Pointer to 2D array.
>
> typedef int (*two_d_t)[X][Y];
>
> If u don't mine can u please explain me this. Becoz I never
> come across this one.
C language follows a simple philosophy that the declaration of a variable should
match the use of variable. For example, if you declare a two-dimensional array
as int a[4][5];, then it is used as, say, a[2][3].
C also follows a simple philosophy about pointer declarations: a POINTER TO
a given type is declared by surrounding a variable of that type between "(*"
and ")". Following examples should be able to throw some light:
int i; /* an integer */
int (*pi); /* a POINTER to an integer */
int *pi; /* parentheses are redundant here, as there is no priority
conflicts */
int ia[4]; /* an array four of integers */
int (*pia)[4]; /* a POINTER to an array four of integers; parentheses are
needed because "[]" has higher priority than "*" */
int *iap[4]; /* an array four of integer pointers */
int ib[4][5]; /* an array four of array five of integers */
int (*pib)[4][5]; /* a POINTER to an array four of array five
of integers */
int fn ( void ); /* a function returning an integer, no parameters */
int (*pfn) ( void ); /* a POINTER to function returning an integer,
no parameters */
int *fnp ( void ); /* Note: fnp is NOT a pointer to function, but it
returns a pointer to an integer */
int (* (*p) )[4][5]; /* Try interpreting this; it should be easier
by now */
int *(*piap)[4]; /* How about this? */
>
> And is there any otherway to pass an array from a function
> which will reflect in main().
>
You can not pass an array as an object to a function. You can pass the pointer
to the first element of the array, or a pointer to the array itself. For
example,
int a[4];
/* ... */
fn ( a ); /* prototype: void fn ( int * ); */
fn2 ( &a ); /* prototype: void fn ( int (*)[] ); */
> I will be very greatfull if you reply me..
>
> Thanks & Reagrd's
>
> Vamsi Krishna.K
> Software Engineer
> Satyam Computers[SCSL]
> Bangalore.
               (
geocities.com/vijoeyz/faq)                   (
geocities.com/vijoeyz)