Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: A string pointer to a static or dynamic string : how to free the dynamic one ? Date: Sun, 22 Jan 2023 11:00:50 -0800 Organization: None to speak of Lines: 44 Message-ID: <871qnmiecd.fsf@nosuchdomain.example.com> References: <61d28ae0-d30f-47f7-adc2-bdadfd20d443n@googlegroups.com> <87a62bie22.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader01.eternal-september.org; posting-host="a96db803e771599752dfc0089ea20ee1"; logging-data="3383611"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kffPmffUfQ7T5aqGbMNS6" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:IHFXfs/YoRYYY3zRo0DZhc36dRE= sha1:h6KcJIO5Yib0GOawjNZ2XyHdZSo= Xref: csiph.com comp.lang.c++:88720 jak writes: > Il 22/01/2023 12:29, Bo Persson ha scritto: >> On 2023-01-22 at 12:17, jak wrote: >>> Il 22/01/2023 11:20, James Kuyper ha scritto: >>>> On 1/22/23 04:46, jak wrote: >>>>> Il 22/01/2023 01:54, Keith Thompson ha scritto: >>>> ... >>>>>> A *pointer to a string* is by definition "a pointer to its initial >>>>>> (lowest addressed) character".  Most manipulation of strings in C is >>>>>> done via string pointers. >>>> ...> pointer to a string? by definition? string pointers? Maybe you are >>>>> confusing programming languages. The C language has no string pointers. >>>> >>>> When he said "by definition", he meant it: >>>> >>>> "A _pointer to a string_ is a pointer to its initial (lowest addressed) >>>> character." (C standard (n2731) 7.1.1p1). >>> >>> "pointer to a string" could be a pointer at the first element of an >>> array that contains a string, perhaps. >> No, not "perhaps", but definitely. The term "pointer to a string" IS >> a pointer to the first element of an array that contains a >> string. That's what it says. >> There are other pointers that can point to a char that is not part >> of a string. Those are then not "pointer to a string". > > ISO standard can cancel that definition because the C does not have > strings but only an agreement that allows the functions to use array as > strings. That is both off-topic and incorrect. C does not have a string type. C certainly does have strings. The definition is quoted above. The C standard makes extensive use of the term "string", particularly in the library section. The meaning is clear and unambiguous. Removing the definition from the language would require a great deal of work to update the standard, and would have no benefit. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */