Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #20398

Re: strchr with its second argument = 0

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.c
Subject Re: strchr with its second argument = 0
Date 2012-05-04 19:53 +0000
Organization Aioe.org NNTP Server
Message-ID <20120504123921.569@kylheku.com> (permalink)
References <jo17lh$g8u$1@news.belwue.de> <20120504123326.903@kylheku.com>

Show all headers | View raw


On 2012-05-04, Kaz Kylheku <kaz@kylheku.com> wrote:
> On 2012-05-04, Thomas Richter <thor@math.tu-berlin.de> wrote:
>> Hi folks,
>>
>> what is the behavior of strchr if the second argument (the character to 
>> be searched for) is set to zero? Does it find the end of the string, or 
>> does it find nothing and should it return NULL?
>
> It should find nothing and return null. The null character isn't a character
> which is in the string. By definition of a C string, a C string cannot contain
> the null character.

Sorry; that's wrong! I was staring at the definition in C99, and somehow read
that as "the terminating null character is *not* considered  part of the
string"; but the word "not" is not there.

(Of course; why would such text even be included other than to give a special
exception to the definition of a string.)

Still, this text actually poor. "Part of the string": does that mean part of
the representation of the string, or part of the string data?  Of course a null
is part of every correct C string. But it's not considered part of the abstract
string.  The intent is clear though.

-- 
If you ever need any coding done, I'm your goto man!

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

strchr with its second argument = 0 Thomas Richter <thor@math.tu-berlin.de> - 2012-05-04 20:37 +0200
  Re: strchr with its second argument = 0 Ralf Damaschke <rwspam@gmx.de> - 2012-05-04 18:45 +0000
  Re: strchr with its second argument = 0 Kaz Kylheku <kaz@kylheku.com> - 2012-05-04 19:49 +0000
    Re: strchr with its second argument = 0 Kaz Kylheku <kaz@kylheku.com> - 2012-05-04 19:53 +0000
      Re: strchr with its second argument = 0 pete <pfiland@mindspring.com> - 2012-05-04 19:31 -0400
        Re: strchr with its second argument = 0 Kaz Kylheku <kaz@kylheku.com> - 2012-05-05 02:22 +0000
  Re: strchr with its second argument = 0 pete <pfiland@mindspring.com> - 2012-05-04 19:39 -0400

csiph-web