Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C String terminator Date: Tue, 14 Jan 2020 11:37:18 -0800 Organization: None to speak of Lines: 42 Message-ID: <87d0blkexd.fsf@nosuchdomain.example.com> References: <303beb4a-dd99-4dbd-bbb7-eb8a07632526@googlegroups.com> <7b60b22b-5f08-418a-a9af-e1b9a11c1626@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="82bcf7564d3c8a4241825d0cfaff7555"; logging-data="1715"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9znRLDab9oj9MADpOLAHd" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:wkVywMA7iJLuCHic3PiOHgZzJ/A= sha1:WVmh49MYJgRKH3+WQNUggXXX514= Xref: csiph.com comp.lang.c:149097 Malcolm McLean writes: > On Tuesday, 14 January 2020 17:43:19 UTC, T wrote: [...] >> Any idea where in the ISO the nul is documented? >> > From one version of the standard > > In translation phase 7, a byte or code of value zero is appended to > each multibytecharacter sequence that results from a string literal or > literals. > > It's in the section "string literals", 6.4.5 That's not directly relevant. String literals and strings are two different things. String literals in source code *usually* result in strings at run time, but not always. For example, the string literal "foo\0bar" results in an 8-character array whose contents are not a string. And there are plenty of ways to construct strings without using string literals: char s[4]; s[0] = 'f'; s[1] = 'o'; s[2] = 'o'; s[3] = 0; The answer to the OP's question is 7.1.1 paragraph 1: A *string* is a contiguous sequence of characters terminated by and including the first null character. The word "string" is in italics, so that's the definition of the term. You can certainly have arrays of characters that are not terminated by a null character, but such an array (or rather its content) is not a "string". -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com [Note updated email address] Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */