Zero Length Arrays Allowed in C Standard?
Maarten Litmaath
maart at cs.vu.nl
Thu Dec 7 07:55:54 AEST 1989
In article <1989Dec5.112553.24087 at twwells.com>
bill at twwells.com (T. William Wells) writes:
\...
\Consider a symbol table that is used to store strings. You could
\declare a member of it as:
\
\ typedef struct SYMTAB {
\ struct SYMTAB *sym_next;
\ int sym_type;
\ char *sym_text;
\ } SYMTAB;
\
\This has the drawback that one needs two allocates for the
\structure [...]
symtabptr = (SYMTAB *) malloc(sizeof(SYMTAB) + strlen(text) + 1);
symtabptr->sym_text = (char *) symtabptr + sizeof(SYMTAB);
strcpy(symtabptr->sym_text, text);
--
`Take John Berryhill: the guy is everywhere! All because one day he typed "rn"
instead of [rm]' (Richard Sexton) | maart at cs.vu.nl, uunet!mcsun!botter!maart
More information about the Comp.lang.c
mailing list