Deutsch English Français Italiano |
<usdleg$1ambo$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> Newsgroups: comp.lang.c Subject: Re: Implicit String-Literal Concatenation Date: Thu, 7 Mar 2024 16:17:20 -0800 Organization: A noiseless patient Spider Lines: 45 Message-ID: <usdleg$1ambo$1@dont-email.me> References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me> <urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me> <urnbh6$3t14d$1@dont-email.me> <87frxcuv87.fsf@nosuchdomain.example.com> <urq4fe$lapm$1@dont-email.me> <urq7fd$lupv$1@dont-email.me> <urqrsu$q361$1@dont-email.me> <87o7bzrll5.fsf@nosuchdomain.example.com> <urquvb$qn8n$2@dont-email.me> <87bk7ysysj.fsf@nosuchdomain.example.com> <us6876$3jpc3$5@dont-email.me> <87y1axp9a7.fsf@nosuchdomain.example.com> <usdad0$18du3$3@dont-email.me> <20240307133736.732@kylheku.com> <87o7bpof0z.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 8 Mar 2024 00:17:20 -0000 (UTC) Injection-Info: dont-email.me; posting-host="c15478cdd59e0ca934cfd72d78b3f41f"; logging-data="1399160"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1eDbLEh+T3xzYTlnFAIXr5CH7r5RE8YI=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:iWZP28FICzMt4iGaBMg+zAUCMg4= Content-Language: en-US In-Reply-To: <87o7bpof0z.fsf@nosuchdomain.example.com> Bytes: 3308 On 3/7/2024 2:25 PM, Keith Thompson wrote: > Kaz Kylheku <433-929-6894@kylheku.com> writes: >> On 2024-03-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote: >>> On Mon, 04 Mar 2024 20:55:28 -0800, Keith Thompson wrote: >>>> Lawrence D'Oliveiro <ldo@nz.invalid> writes: >>>>> On Thu, 29 Feb 2024 14:14:52 -0800, Keith Thompson wrote: >>>>>> "A *string* is a contiguous sequence of characters terminated by and >>>>>> including the first null character." >>>>> >>>>> So how come strlen(3) does not include the null? >>>> >>>> Because the *length of a string* is by definition "the number of bytes >>>> preceding the null character". >>> >>> So the “string” itself includes the null character, but its “length” does >>> not? >> >> That's correct. However, its size includes it. >> >> sizeof "abc" == 4 >> >> strlen("abc") == 3 >> >> The abstract string does not include the null character; >> we understand "abc" to be a three character string. > > Sure, if you define "abstract string" that way. I'll just note that C's > definition of the word "string" does include the terminating null > character, and does not talk about "abstract strings". (A string in the > abstract machine clearly includes the null character, but that's a bit > of a stretch.) > > Yes, I'm being annoyingly pedantic. :^D The ADA vs Ada was a little pedantic, so to speak. ;^) > >> The C representation of the string includes the null character; >> the size is a representational concept so it counts it. >> >> It is common for C programs to break encapsulation and openly deal with >> that terminating null. >