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 11:37:20 -0700 Organization: None to speak of Lines: 52 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="17144"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ld+3RpLaBiB9fUZkN3zGf" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Kf+44BVl8kA2F13A7ugb8I1AhDI= sha1:ew3Isa5M+P6DzhoDkilVjDSSfSI= Xref: csiph.com comp.lang.c:109523 bartc writes: > On 08/05/2017 17:00, Keith Thompson wrote: [...] >> I think you meant that arrays of pointers to arrays would be unusual. > > No, I mean arrays of pointers to strings, with a string meaning char*. > The variable names I've chosen should make it clear that: > > str (ie. string) is a char* > ptr_to_str is char** > > and so on. Then you are using terminology that is clearly defined by the C standard in a manner inconsistent with the way the standard uses it. > Since it is impossible to work with an actual string itself, it's more > useful I think for 'string' to be a synonym for 'char*'. Whether it would have been more useful or not, the standard clearly defines the terms "string" and "pointer to string" in 7.1.1p1, which I've recently quoted elsewhere in this thread. >> A "pointer to a string" is by definition a pointer to the initial >> character of a string. > > AFAIK C has no such concept. Well now you know that it does. > It only has pointer to char. Or, rarely, a > pointer to an entire array, of which the contents may contain a > zero-terminated string. One more time, N1570 7.1.1p1 (with asterisks to represent italics, which denote a definition of a term): A *string* is a contiguous sequence of characters terminated by and including the first null character. The term *multibyte string* is sometimes used instead to emphasize special processing given to multibyte characters contained in the string or to avoid confusion with a wide string. A *pointer to a string* is a pointer to its initial (lowest addressed) character. Feel free to dislike those definitions, but at least consider acknowledging their existence in the C standard. -- 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"