Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Never trust a computer you can't repair yourself.


devel / comp.lang.c / Re: Implicit String-Literal Concatenation

SubjectAuthor
* Implicit String-Literal ConcatenationLawrence D'Oliveiro
+* Re: Implicit String-Literal ConcatenationJanis Papanagnou
|`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
| `- Re: Implicit String-Literal Concatenationbart
+- Re: Implicit String-Literal ConcatenationBlue-Maned_Hawk
+- Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
+* Re: Implicit String-Literal ConcatenationŁukasz 'Maly' Ostrowski
|`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
| `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
|  `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
|   `- Re: Implicit String-Literal ConcatenationJanis Papanagnou
+- Re: Implicit String-Literal ConcatenationKaz Kylheku
`* Re: Implicit String-Literal ConcatenationMike Sanders
 +* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
 |`- Re: Implicit String-Literal ConcatenationMike Sanders
 `* Re: Implicit String-Literal ConcatenationDavid Brown
  +- Re: Implicit String-Literal ConcatenationMike Sanders
  +* Re: Implicit String-Literal Concatenationbart
  |`* Re: Implicit String-Literal ConcatenationDavid Brown
  | `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |  `* Re: Implicit String-Literal ConcatenationKaz Kylheku
  |   `* Re: Implicit String-Literal ConcatenationDavid Brown
  |    `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |     +* Re: Implicit String-Literal Concatenationbart
  |     |`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |     | `* Re: Implicit String-Literal Concatenationbart
  |     |  +* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |     |  |`- Re: Implicit String-Literal Concatenationbart
  |     |  `* Re: Implicit String-Literal ConcatenationScott Lurndal
  |     |   `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |    `* Re: Implicit String-Literal ConcatenationScott Lurndal
  |     |     +* Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |     |`* Re: Implicit String-Literal ConcatenationScott Lurndal
  |     |     | `* Re: Implicit String-Literal ConcatenationKeith Thompson
  |     |     |  `* Re: Implicit String-Literal Concatenationbart
  |     |     |   `* Re: Implicit String-Literal ConcatenationKeith Thompson
  |     |     |    `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |     |     `* Re: Implicit String-Literal ConcatenationKeith Thompson
  |     |     |      `- Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |     `- Re: Implicit String-Literal ConcatenationKeith Thompson
  |     `* Re: Implicit String-Literal ConcatenationDavid Brown
  |      `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |       `* Re: Implicit String-Literal ConcatenationDavid Brown
  |        `* Re: Implicit String-Literal ConcatenationKaz Kylheku
  |         `- Re: Implicit String-Literal ConcatenationDavid Brown
  `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
   +* Re: Implicit String-Literal ConcatenationKeith Thompson
   |`- Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
   `* Re: Implicit String-Literal Concatenationbart
    `* Re: Implicit String-Literal ConcatenationDavid Brown
     +* Re: Implicit String-Literal Concatenationbart
     |+- Re: Implicit String-Literal ConcatenationDavid Brown
     |+* Re: Implicit String-Literal ConcatenationKeith Thompson
     ||+* Re: Implicit String-Literal ConcatenationMalcolm McLean
     |||+* Re: Implicit String-Literal ConcatenationDavid Brown
     ||||`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     |||| +- Re: Implicit String-Literal ConcatenationKeith Thompson
     |||| `* Re: Implicit String-Literal ConcatenationRichard Harnden
     ||||  `- Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     |||`- Re: Implicit String-Literal ConcatenationKeith Thompson
     ||`* Re: Implicit String-Literal Concatenationbart
     || +* Re: Implicit String-Literal ConcatenationRichard Harnden
     || |`* Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || | `* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |  `* Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || |   `* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |    +- Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || |    `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     || |     `* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |      `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     || |       +* Re: Implicit String-Literal ConcatenationKaz Kylheku
     || |       |`* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |       | +* Re: Implicit String-Literal ConcatenationKaz Kylheku
     || |       | |`- Re: Implicit String-Literal ConcatenationKeith Thompson
     || |       | +- Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || |       | `- Re: Implicit String-Literal ConcatenationRichard Harnden
     || |       `- Re: Implicit String-Literal ConcatenationKeith Thompson
     || +* Re: Implicit String-Literal ConcatenationDavid Brown
     || |`- Re: Implicit String-Literal ConcatenationKeith Thompson
     || `* Re: Implicit String-Literal ConcatenationKeith Thompson
     ||  `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
     ||   `* Re: Implicit String-Literal ConcatenationKeith Thompson
     ||    `* Re: Implicit String-Literal ConcatenationKaz Kylheku
     ||     `- Re: Implicit String-Literal ConcatenationJames Kuyper
     |`- Re: Implicit String-Literal ConcatenationKeith Thompson
     `* Re: Implicit String-Literal ConcatenationKeith Thompson
      +* Re: Implicit String-Literal Concatenationbart
      |`* Re: Implicit String-Literal ConcatenationKeith Thompson
      | `* Re: Implicit String-Literal Concatenationbart
      |  +- Re: Implicit String-Literal ConcatenationKeith Thompson
      |  +* Re: Implicit String-Literal ConcatenationtTh
      |  |`- Re: Implicit String-Literal ConcatenationScott Lurndal
      |  `* Re: Implicit String-Literal ConcatenationScott Lurndal
      |   `* Re: Implicit String-Literal ConcatenationKeith Thompson
      |    `* Re: Implicit String-Literal ConcatenationScott Lurndal
      |     `* Re: Implicit String-Literal ConcatenationDavid Brown
      |      `* Re: Implicit String-Literal ConcatenationScott Lurndal
      |       +* Re: Implicit String-Literal ConcatenationScott Lurndal
      |       |`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
      |       | `* Re: Implicit String-Literal Concatenationbart
      |       |  `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
      |       `- Re: Implicit String-Literal ConcatenationDavid Brown
      `* Re: Implicit String-Literal ConcatenationDavid Brown

Pages:12345
Re: Implicit String-Literal Concatenation

<87y1axp9a7.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34126&group=comp.lang.c#34126

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Mon, 04 Mar 2024 20:55:28 -0800
Organization: None to speak of
Lines: 19
Message-ID: <87y1axp9a7.fsf@nosuchdomain.example.com>
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>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1a8f7ad2f6e687631fe43fc4c823263c";
logging-data="3794616"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NTyzGBW3+N+oB6f7ihDFy"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:vRA3jocqCUFvxPVtyDuNNZrVtZo=
sha1:MiwCNbHX7V2e/xSd2YIN+MVObjk=
 by: Keith Thompson - Tue, 5 Mar 2024 04:55 UTC

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".

Why is it defined that way? Because it's more useful than the
alternative.

See 7.1.1 paragraph 1 in any edition or draft of the C standard.

--
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 */

Re: Implicit String-Literal Concatenation

<mAGFN.115189$m4d.8674@fx43.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34152&group=comp.lang.c#34152

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx43.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me> <87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me> <AL1EN.511040$xHn7.220429@fx14.iad> <875xy7td2o.fsf@nosuchdomain.example.com> <593EN.22560$zF_1.19152@fx18.iad> <urqgkq$nt9f$1@dont-email.me> <2I3EN.637365$p%Mb.40952@fx15.iad> <QL3EN.637366$p%Mb.580728@fx15.iad> <urqsso$q9h9$3@dont-email.me> <ursfhg$17dak$1@dont-email.me> <us684m$3jpc3$4@dont-email.me>
Lines: 22
Message-ID: <mAGFN.115189$m4d.8674@fx43.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 05 Mar 2024 15:09:06 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 05 Mar 2024 15:09:06 GMT
X-Received-Bytes: 1822
 by: Scott Lurndal - Tue, 5 Mar 2024 15:09 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>On Fri, 1 Mar 2024 11:52:16 +0000, bart wrote:
>
>> On 29/02/2024 21:27, Lawrence D'Oliveiro wrote:
>>
>>> On Thu, 29 Feb 2024 18:09:52 GMT, Scott Lurndal wrote:
>>>
>>>> I have an actual use case today where #embed of a (C++) std::map
>>>> binary object created by separate tool would be very useful. I'm
>>>> planning on using mmap to load it at runtime at the moment.
>>>
>>> Why not convert it to a .o file and statically link it into your
>>> program as part of the build process?
>>
>> That's exactly what #embed will enable.
>
>You can call it a toy version of objcopy
><https://manpages.debian.org/1/objcopy.1.html>.

While objcopy supports a number of ways to
manipulate an ELF file, I wouldn't equate it
with #embed at all.

Re: Implicit String-Literal Concatenation

<us8i3g$24j7$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34166&group=comp.lang.c#34166

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Wed, 6 Mar 2024 01:49:36 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <us8i3g$24j7$2@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me>
<877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me>
<87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me>
<AL1EN.511040$xHn7.220429@fx14.iad>
<875xy7td2o.fsf@nosuchdomain.example.com> <593EN.22560$zF_1.19152@fx18.iad>
<urqgkq$nt9f$1@dont-email.me> <2I3EN.637365$p%Mb.40952@fx15.iad>
<QL3EN.637366$p%Mb.580728@fx15.iad> <urqsso$q9h9$3@dont-email.me>
<ursfhg$17dak$1@dont-email.me> <us684m$3jpc3$4@dont-email.me>
<mAGFN.115189$m4d.8674@fx43.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 6 Mar 2024 01:49:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="289fca74fac389e911c3152c39303989";
logging-data="70247"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/csFPL8IpHt2xzUfqGPHfr"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:ARisPsB59OlwBjN5cv3sYpWidL8=
 by: Lawrence D'Oliv - Wed, 6 Mar 2024 01:49 UTC

On Tue, 05 Mar 2024 15:09:06 GMT, Scott Lurndal wrote:

> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>
>>On Fri, 1 Mar 2024 11:52:16 +0000, bart wrote:
>>
>>> On 29/02/2024 21:27, Lawrence D'Oliveiro wrote:
>>>
>>>> On Thu, 29 Feb 2024 18:09:52 GMT, Scott Lurndal wrote:
>>>>
>>>>> I have an actual use case today where #embed of a (C++) std::map
>>>>> binary object created by separate tool would be very useful. I'm
>>>>> planning on using mmap to load it at runtime at the moment.
>>>>
>>>> Why not convert it to a .o file and statically link it into your
>>>> program as part of the build process?
>>>
>>> That's exactly what #embed will enable.
>>
>>You can call it a toy version of objcopy
>><https://manpages.debian.org/1/objcopy.1.html>.
>
> While objcopy supports a number of ways to manipulate an ELF file, I
> wouldn't equate it with #embed at all.

It does a whole lot more.

Re: Implicit String-Literal Concatenation

<usdad0$18du3$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34217&group=comp.lang.c#34217

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 7 Mar 2024 21:08:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <usdad0$18du3$3@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Mar 2024 21:08:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="63d07f27dc2a6beb992a482a5dec0d77";
logging-data="1324995"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bBzLp5fNhuHFT6mX9Enq4"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:vln3hIGmK0PHCW6GkVRmTQUj7Bg=
 by: Lawrence D'Oliv - Thu, 7 Mar 2024 21:08 UTC

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?

Re: Implicit String-Literal Concatenation

<20240307133736.732@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34218&group=comp.lang.c#34218

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 7 Mar 2024 21:44:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <20240307133736.732@kylheku.com>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Mar 2024 21:44:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d4c5da8a4cdb9a5a7101a267b3941499";
logging-data="1340440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Rl+39ZVybtLqLu44bP2mwQxqpK6zaZBI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:UKgw7TiJoNSTns27F50yjucSy7U=
 by: Kaz Kylheku - Thu, 7 Mar 2024 21:44 UTC

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.

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.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Implicit String-Literal Concatenation

<87sf11ofg6.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34219&group=comp.lang.c#34219

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 07 Mar 2024 14:16:41 -0800
Organization: None to speak of
Lines: 35
Message-ID: <87sf11ofg6.fsf@nosuchdomain.example.com>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="baf60ccaa3a113314bb7d61097e89b2c";
logging-data="1351775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19f1ZFEKRy9qVlpXfxq32Ht"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:7leEEBwHDHfM22qFwXk68HM9qko=
sha1:gSOuxquRUu/xZIQLOHL74Bafglk=
 by: Keith Thompson - Thu, 7 Mar 2024 22:16 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> 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?

Yes, as you can easily see if you read 7.1.1p1 for yourself.

I can't tell if you're trying to understand C strings, or you're
suprised by how they're defined, or you object to how they're defined,
or you don't accept how they're defined, or something else. I'm getting
the impression that you're arguing for the sake of arguing, but perhaps
that's unfair of me. If you have a wider point, perhaps you could let
us know what it is.

I'll also note that you asked why strlen() doesn't include the null, I
answered, and you snipped most of my answer. Of course there's usually
no need to quote all of an article you're replying to, but it would be
helpful if you'd mark your deletions. (I usually use "[...]".) You've
given the impression that I gave you just a one-sentence answer to your
question, which is not the case.

--
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 */

Re: Implicit String-Literal Concatenation

<87o7bpof0z.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34220&group=comp.lang.c#34220

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 07 Mar 2024 14:25:48 -0800
Organization: None to speak of
Lines: 43
Message-ID: <87o7bpof0z.fsf@nosuchdomain.example.com>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="baf60ccaa3a113314bb7d61097e89b2c";
logging-data="1351775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/O7ylGvF3oy2wayaGtOrpk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:m+HSQz4b/AA9D0QIKdRbZ7Qf1Bs=
sha1:ZAwlmcELeYbs0CW07LfDrdSGHfk=
 by: Keith Thompson - Thu, 7 Mar 2024 22:25 UTC

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.

> 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.

--
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 */

Re: Implicit String-Literal Concatenation

<20240307145137.99@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34221&group=comp.lang.c#34221

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 7 Mar 2024 23:00:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <20240307145137.99@kylheku.com>
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
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Mar 2024 23:00:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5d62f51bcdd3fa281d3b0240a90726ac";
logging-data="1368912"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CtdkiYlTkDUiuJGitKXmtLBhIuiBJo5o="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:iDo61w8cfK0n9/1qVBx/HsZCWiE=
 by: Kaz Kylheku - Thu, 7 Mar 2024 23:00 UTC

On 2024-03-07, Keith Thompson <Keith.S.Thompson+u@gmail.com> 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; "abstract machine" is not what I mean by abstract.

The concept of the abstract string lives in the semantics though.

When N strings are catenated together, their abstract strings are
juxtaposed together without any nulls in between, with only a single
null at the end.

Furthermore, when a string is sent to a stream with %s or {f}puts,
the null byte is omitted, like in the calculation of length.

Clearly, there is a semantics that the part before the null byte
is the text processing payload; what I'm calling the abstract string.

(With character encodings, it gets hairy. The part before the null
may be a UTF-8 sequence, where the abstract string consists of code
points. Which may be combining characters, so the True Scotsman's
abstract string is the sequence of characters.)
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Implicit String-Literal Concatenation

<87frx1obba.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34225&group=comp.lang.c#34225

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 07 Mar 2024 15:46:01 -0800
Organization: None to speak of
Lines: 87
Message-ID: <87frx1obba.fsf@nosuchdomain.example.com>
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>
<20240307145137.99@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="ba4161de3c6afa3b79edb2bdfdc78ddd";
logging-data="1388589"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191txyRFnv8+kTJo+6U7CLA"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:1vOuYIvAQ+5gQgTd7+PMyLLDOvo=
sha1:vbmAdreZwyfJpTSK2t4s+zvkx34=
 by: Keith Thompson - Thu, 7 Mar 2024 23:46 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> On 2024-03-07, Keith Thompson <Keith.S.Thompson+u@gmail.com> 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; "abstract machine" is not what I mean by abstract.
>
> The concept of the abstract string lives in the semantics though.
>
> When N strings are catenated together, their abstract strings are
> juxtaposed together without any nulls in between, with only a single
> null at the end.

True both for compile-time string literal catenation and for strcat().

But for the former, embedded null characters can slightly complicate
matters. The value of a string literal isn't necessarily a string.

#include <stdio.h>
int main(void) {
const char s[] = "abc\0def" "ghi\0";
puts(s);
for (size_t i = 0; i < sizeof s; i ++) {
if (s[i] == '\0') {
fputs("\\0", stdout);
}
else {
putchar(s[i]);
}
}
putchar('\n');
}

Output:
abc
abc\0defghi\0\0

> Furthermore, when a string is sent to a stream with %s or {f}puts,
> the null byte is omitted, like in the calculation of length.
>
> Clearly, there is a semantics that the part before the null byte
> is the text processing payload; what I'm calling the abstract string.

Agreed. To be clear, I like the idea of referring to the contents of a
string excluding the terminating null character as an "abstract string".

> (With character encodings, it gets hairy. The part before the null
> may be a UTF-8 sequence, where the abstract string consists of code
> points. Which may be combining characters, so the True Scotsman's
> abstract string is the sequence of characters.)

Yes. With UTF-8, the term "abstract string" might reasonably refer
either to the sequence of bytes preceding the terminating '\0', or to
the sequence of code points.

--
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 */

Re: Implicit String-Literal Concatenation

<usdleg$1ambo$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34226&group=comp.lang.c#34226

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
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>
 by: Chris M. Thomasson - Fri, 8 Mar 2024 00:17 UTC

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.
>

Re: Implicit String-Literal Concatenation

<usdlus$1apqi$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34228&group=comp.lang.c#34228

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Fri, 8 Mar 2024 00:26:04 +0000
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <usdlus$1apqi$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>
Reply-To: nospam.harnden@invalid.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:26:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="db5957b39d2d87cc21678d3d28ac2828";
logging-data="1402706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rLFlU59quPKvtb54EwJ3Piadq72bNzyI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:47f3/3SGTf7oFlOcVsMECGUenLM=
Content-Language: en-GB
In-Reply-To: <87o7bpof0z.fsf@nosuchdomain.example.com>
 by: Richard Harnden - Fri, 8 Mar 2024 00:26 UTC

On 07/03/2024 22:25, 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.)

A string is just a data format.

You have a string of chars, terminated by a '\0'.

You can have a "string" of anything, terminated by a NULL.
Everyone's used to argv, for example.

>
> Yes, I'm being annoyingly pedantic.
>
>> 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.
>

Pages:12345
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor