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: error: initializer element is not constant| Date: Mon, 08 May 2017 09:00:50 -0700 Organization: None to speak of Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="6d7e0aa3e5b7ac222e8546bcb39ccb10"; logging-data="2569"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CoU1U9YNuBTEZcaRbeKJ8" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Td2jKrpCs1b6h2+ZEnZaUR7cmBQ= sha1:P5ahHo2ngVg6Ir3c89CwtnSA6ls= Xref: csiph.com comp.lang.c:109504 bartc writes: [...] > Those types would look like this without typedefs: > > char * str; > char * array_of_str[]; > char ** ptr_to_str; > char ** array_of_ptr_to_str[]; > > (The arrays will need a dimension, or need to be initialised.) > > But arrays of pointers to strings would be unusual, and be harder to > initialise as you can't just have "ABC", but need to set up a named > string: char* abc="ABC", then use &abc. I think you meant that arrays of pointers to arrays would be unusual. A "pointer to a string" is by definition a pointer to the initial character of a string. Arrays of pointers to strings are quite common; for example, argv points to the initial element of such an array. [...] -- 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"