Functions returning pointers to functions

George Hart george at mnetor.UUCP
Fri Jul 19 00:37:07 AEST 1985


I'm sorry I've lost the original reference but someone asked
how to declare a function returning a pointer to a function
(returning whatever).

Here's some trivial code that illustrates one way.  Using typedef's is better
way especially if you are going to use multiple levels of indirection
(maybe not a good idea to begin with).

extern int printf();

main()
{
    int (*func())();

    (func())("This is the %dst string.\n",1);
}

int (*func())()
{
    return(printf);
}

-- 


Regards,

George Hart, Computer X Canada Ltd.
UUCP: {allegra|decvax|linus|ihnp4}!utzoo!mnetor!george
BELL: (416)475-8980



More information about the Comp.lang.c mailing list