Path: csiph.com!news.mixmin.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: Mon, 23 Jan 2023 13:26:25 -0800 Organization: None to speak of Lines: 33 Message-ID: <87v8kxeyda.fsf@nosuchdomain.example.com> References: <61d28ae0-d30f-47f7-adc2-bdadfd20d443n@googlegroups.com> <87a62bie22.fsf@nosuchdomain.example.com> <5e8ec0f6-02cf-403a-918a-710c4fc569a7n@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="d34d0f49d825817f6e40612c0dbcdea1"; logging-data="3979873"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fTtRz40SCYkDswju5JhgW" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:B8H3L0jmk4EDy/kjS87APElqjsE= sha1:Chfzn7mf4oi68OHpaiP2Njv5XHQ= Xref: csiph.com comp.lang.c++:88788 Malcolm McLean writes: > On Monday, 23 January 2023 at 13:42:53 UTC, David Brown wrote: >> C's concept of a string is different from (and more low-level and >> primitive than) that found in many other programming languages. But >> that does not mean C does not have strings, defined in the standards and >> as part of the language and standard library. >> > The language states that a text literal in double quotes produces a nul-terminated > string. I think that's the only place the C language itself defines a string. Otherwise > it is purely a standard library concept. No, it doesn't say that. The standard's description of string literals (N1570 6.4.5) does not refer to the standard's definition of "string" (N1570 7.1.1). Consider, for example, "abc\0def". Sections 6 and 7 are both equally valid parts of the C standard. (Most of section 7 is optional for freestanding implementations, but 7.1.1 is not, though the concept of a "string" is less useful in an implementation that doesn't provide library functions that manipulate strings). (A side note: As far as I can tell, N1570 6.4.5 describes the syntax and semantics of a string literal, but never actually says what the value of a string literal is. It's obvious that it's the value of the described array object, but I don't think it actually says so. This is not relevant to the current discussion.) -- 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 */