Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!decwrl!shelby!bloom-beacon!eru!luth!sunic!mcsun!hp4nl!orcenl!bengsig From: bengsig@oracle.nl (Bjorn Engsig) Newsgroups: comp.lang.c Subject: Re: Zero Length Arrays Allowed in C Standard? Message-ID: <565.nlhp3@oracle.nl> Date: 7 Dec 89 09:32:23 GMT References: <2298@jato.Jpl.Nasa.Gov> <11715@smoke.BRL.MIL> <480@codonics.COM> <1989Dec2.210042.12668@twwells.com> <8129@cg-atla.UUCP> <1989Dec5.112553.24087@twwells.com> <11963@phoenix.Princeton.EDU> <11751@smoke.BRL.MIL> Reply-To: bengsig@oracle.nl (Bjorn Engsig) Organization: ORACLE Europe, The Netherlands Lines: 21 Article <11751@smoke.BRL.MIL> by gwyn@brl.arpa (Doug Gwyn) says: |I use the [1] kludge on occasion, but I raise flags when I do because |it is not guaranteed to work. Would you please explain why, and also tell what is the portable way of having a 'variable length "thing"' in C. Article <4733@solo11.cs.vu.nl> by maart@cs.vu.nl (Maarten Litmaath) proposed: | typedef struct SYMTAB { | struct SYMTAB *sym_next; | int sym_type; | char *sym_text; | } SYMTAB; | |symtabptr = (SYMTAB *) malloc(sizeof(SYMTAB) + strlen(text) + 1); |symtabptr->sym_text = (char *) symtabptr + sizeof(SYMTAB); |strcpy(symtabptr->sym_text, text); Is that portable, or do you have to use two mallocs (one for the struct, and one for the string)? -- Bjorn Engsig, Domain: bengsig@oracle.nl, bengsig@oracle.com Path: uunet!{mcsun!orcenl!bengsig,oracle!bengsig}