Is typedef char BUFFER[20] legal?

Stan Brown browns at iccgcc.decnet.ab.com
Tue Feb 5 05:06:26 AEST 1991


In article <22642 at netcom.UUCP>, avery at netcom.UUCP (Avery Colter) writes:
> My instinct right now is telling me that 
> 
> typedef char[20] BUFFER
> 
> is more consistent...
> 
> But I'll take the word of the more experienced that the first def
> can be done too.

    typedef char BUFFER[20];
is legal C.  I believe that what you wrote is not legal C.

The general rule for writing typedefs is: write a normal variable
declaration, stick 'typedef' on the front, and the variable name becomes
the type name.  Thus BUFFER is the name of a type that is array (20
long) of char.

Hey--this is all my opinion, nobody else's. Rely on it at your peril.
                                   email: browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA    +1 216 371 0043



More information about the Comp.lang.c mailing list