How do I declare...

Joe Mueller joemu at nsc-pdc.UUCP
Tue Aug 27 09:46:18 AEST 1985


> Thus, if you want an array of pointers to arrays of pointers, you can't
> do it.  Nor can you declare functions returning pointers to functions.

You have to be kidding, you can declare both of these things although the
syntax may be a little weird.

Here's an array of 5 pointers to arrays of 6 pointers to char
	char *(*foo[5])[6]	/* how do you like that sports fans! */

Here's a function returning a pointer to a function returning an int
	int (*foo())()

If you have trouble declaring things or deciphering existing code, I highly
recommend a utility called "cdecl". It takes an english description of what
you want and gives you the C syntax for it, it will also take a C declaration
and translate it to an english description of what it is. I used it on the
above examples so I got the declaration right the first time with minimal fuss.
It has been posted to the net at least once before, if you absolutely can't
find it elsewhere and you want a copy, I'll send it to you. If too many people
need it, I'll post it to the net.

The language has hooks to declare incredibly complex data structures, if your
compiler can't hack it, it's not the language's fault.



More information about the Comp.lang.c mailing list