Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Dinamic array without malloc - Can be done? Date: Sun, 15 Jan 2017 12:43:30 -0800 Organization: None to speak of Lines: 19 Message-ID: References: <863e4550-027a-4d32-b5df-e34f2c7b4439@googlegroups.com> <219f0a4a-dbe2-4ecc-b534-bd55b50fd184@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="a3056e3d6a9ef9101ceee550b325befe"; logging-data="4387"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18NYwb+iidJFImsaYZScgnS" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:0MxR23Qh4jFtOJsUW2CaCdl6Ccc= sha1:KP5pP+K45XD16kg6MwSLCeaI+0I= Xref: csiph.com comp.lang.c:101879 BartC writes: > On 15/01/2017 18:42, Fernando D. Bozzo wrote: [...] >> myArray[0] = 'A'; >> myArray[1] = '\0'; > > This assumes that len is at least two. And below, that it is a least 4. > But len can be 0 or 1. C does not permit array of length 0, though some compilers may support them as an extension. For a non-VLA, defining a 0-length array is a constraint violation; for a VLA, it's undefined behavior (which a compiler might warn about if it has enough information). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"