Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!ncar!boulder!pikes!slate!jedelen From: jedelen@slate.mines.colorado.edu (Jeff Edelen @ Colorado School of Mines) Newsgroups: comp.lang.c Subject: Re: Invoking pointers to functions (C sytle) Message-ID: <1990Dec02.204212.15465@slate.mines.colorado.edu> Date: 2 Dec 90 20:42:12 GMT References: <6379@harrier.ukc.ac.uk> Organization: Colorado School of Mines Lines: 33 In article <6379@harrier.ukc.ac.uk> dac@ukc.ac.uk (David Clear) writes: >Take a look at this: > >main() >{ > int fred(), (*p)(); > > p = fred; > > (*p)(10); /* The right way */ > p(10); /* This works too */ >} > >int >fred(x) >... > >The (*p)(args) invocation is the K&R standard. p(args) also works on at >least 4 different Unix compilers. > >Q: Is p(args) legal, portable C? >Q: Is p(args) preferential to (*p)(args) as it looks neater, compare: > s->p(args) (*s->p)(args) > >Any thoughts? I've only ever used (*p)()... I only came across p() recently. > >Dave. It always seemed to me that p(args) is logically more consistent. If you call the function fred() normally with fred(args) and fred (no parens) is a pointer to the function, then if p is a pointer to the same function, just adding the parens should have the same effect. As for what's legal... anyone? Brought to you by Super Global Mega Corp .com