Array of pointers to functions

Karl Tombre tombre at crin.UUCP
Wed Apr 9 01:52:10 AEST 1986


In article <2398 at brl-smoke.ARPA> woody%Juliet.Caltech.Edu at cit-hamlet.ARPA writes:
>I'm confused.  How do you specify an array of pointers to functions?  Do
>you do it:
>
>           int (*foo[])();
>
>or do you do it:
>
>           int ((*foo)())[];

Your compiler is right of course in taking the first as valid. A you say,
this may not be given in K&R, but I found some equivalence rules in another
book : "Advanced C: food for the educated palate", by N. Gehani, Computer
Science Press (ISBN 0-88175-078-6). You can find out this way:

     foo             : array of pointers to functions returning int
=>   foo[]           : pointer to function returning int
=>   *foo[]          : function returning int
=>   (*foo[])()      : int

and thus you have the right syntax.

I posted this rather than replying as you are not on UUCP and I have already
experienced that mail sent through complex channels does not reach its
destination easily.

Best regards,
-- 
--- Karl Tombre @ CRIN (Centre de Recherche en Informatique de Nancy)
UUCP:    ...!vmucnam!crin!tombre  or    ...!inria!crin!tombre
COSAC:   crin/tombre
POST:    Karl Tombre, CRIN, B.P. 239, 54506 VANDOEUVRE CEDEX, France

Les plus desesperes sont les chants les plus beaux,
Et j'en sais d'immortels qui sont de purs sanglots.

       Alfred de Musset.



More information about the Comp.lang.c mailing list