Array of pointers to functions

William E. Woody woody%Juliet.Caltech.Edu at cit-hamlet.ARPA
Tue Apr 8 09:52:05 AEST 1986


  Yesterday I asked which was right:  "int (*foo[SIZE])()" or
"int ((*foo)())[];" today I got several answers from a few folks out in
net-land.  Thank you everyone for helping me out in this small point of
confusion.  Though I have been using C for a couple of years, up until
today the section of K&R on declaring variables mystified me; now I know
a lot better.

  The solution I got was to look at declarations from the inside out; thus

     int foo                       - An integer
     int *foo                      - A pointer to an integer
     int (*foo)[]                  - An array of pointers to integers
     int ((*foo)[])()              - An array of pointers to functions
                                     returning integers.

  The whole thing reads from inside out, just as english reads from right to
left.

  Thank you very very much for your time and trouble on this one, net landers!
         - William Woody
      NET  Woody%Romeo at Hamlet.Caltech.Edu
   USNAIL  1-54 Lloyd, Caltech / Pasadena, CA 91126



More information about the Comp.lang.c mailing list