Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Implicit String-Literal Concatenation Date: Thu, 29 Feb 2024 13:45:26 -0800 Organization: None to speak of Lines: 47 Message-ID: <87o7bzrll5.fsf@nosuchdomain.example.com> References: <87frxcuv87.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684"; logging-data="873237"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8Icgfe4lhWBCQt6p/mrAH" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:vyDOdfPDQvKep/5RE80Eeq3PRBM= sha1:gWOEY6LOs0LClVS1P1Khrmhkmd0= Xref: csiph.com comp.lang.c:383202 "Chris M. Thomasson" writes: > On 2/29/2024 7:22 AM, Richard Harnden wrote: >> On 29/02/2024 14:31, bart wrote: [...] >>> Not here: >>> >>>      char s[]  = "ABC"; >>>      char t[3] = "DEF"; >>> >>> The "DEF" string doesn't end with a zero. >> And is, therefore, not a string. > [...] > > Right. However, is this a string or two embedded strings: > > char x[] = "ABC\0DEF" Is *what* a string or two embedded strings? x as a whole does not contain a string, but there are 8 strings within it. > _____________________ > #include > > int main() > { > char x[] = "ABC\0DEF"; > > printf("%s\n", x); > printf("%s", x + 4); > > return 0; > } > _____________________ > > Any undefined behavior here? No, and none in this: for (size_t i = 0; i < sizeof x; i ++) { printf("%s\n", x+i); } -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Medtronic void Void(void) { Void(); } /* The recursive call of the void */