devine@vianet.UUCP (Bob Devine) (06/26/86)
Here is a table of how to interpret C declarations. It lists the possible combinations of arrays, pointers, and functions for up to three choices. It also shows what combinations are illegal. I'm posting this because I found it helpful, in its side-by-side display, in explaining tricky declarations (ie, int (*paf)[](); versus int (*apf[])();) for those times when talking it through doesn't help. Let me plug Chris Torek's cdecl program: use of it helps show people how C constructs a declaration. This listing came from Joe Treat. Where he got it is unknown. Bob Devine ------------------------ cut here ---------------------------------------- int i; /* integer */ int *p; /* pointer to integer */ int a[]; /* array of integer */ int f(); /* function returning integer */ int **pp; /* pointer to pointer to int */ int (*pa)[]; /* pointer to array of int */ int (*pf)(); /* pointer to function returning int */ int *ap[]; /* array of pointer to int */ int aa[][]; /* array of array of int */ int af[](); /* array of int functions (ILLEGAL)*/ int *fp(); /* function returning pointer to int */ int fa()[]; /* function returning array of int (ILLEGAL)*/ int ff()(); /* function returning function returning int (ILLEGAL)*/ int ***ppp; /* pointer to pointer to pointer to int */ int (**ppa)[]; /* pointer to pointer to array of int */ int (**ppf)(); /* pointer to pointer to function returning int */ int *(*pap)[]; /* pointer to array of pointer to int */ int (*paa)[][]; /* pointer to array of array of int */ int (*paf)[](); /* pointer to array of function returning int (ILLEGAL)*/ int *(*pfp)(); /* pointer to function returning pointer to int */ int (*pfa)()[]; /* pointer to function returning array of int (ILLEGAL)*/ int (*pff)()(); /* pointer to function returning function returning int (ILLEGAL)*/ int **app[]; /* array of pointer to pointer to int */ int (*apa[])[]; /* array of pointer to array of int */ int (*apf[])(); /* array of pointer to function returning int */ int *aap[][]; /* array of array of pointer to int */ int aaa[][][]; /* array of array of array of int */ int aaf[][](); /* array of array of function returning int (ILLEGAL)*/ int *afp[](); /* array of function returning pointer to int */ int afa[]()[]; /* array of function returning array of int (ILLEGAL)*/ int aff[]()(); /* array of function returning function returning int (ILLEGAL)*/ int **fpp(); /* function returning pointer to pointer to int */ int (*fpa())[]; /* function returning pointer to array of int */ int (*fpf())(); /* function returning pointer to function returning int */ int *fap()[]; /* function returning array of pointer to int (ILLEGAL)*/ int faa()[][]; /* function returning array of array of int (ILLEGAL)*/ int faf()[](); /* function returning array of function returning int (ILLEGAL)*/ int *ffp()(); /* function returning function returning pointer to int (ILLEGAL)*/ int ffa()()[]; /* function returning function returning array of int (ILLEGAL)*/ int fff()()(); /* function returning function returning function returning int (ILLEGAL)*/