Re: A question regarding C string functions

Liste des GroupesRevenir à l c 
Sujet : Re: A question regarding C string functions
De : lew.pitcher (at) *nospam* digitalfreehold.ca (Lew Pitcher)
Groupes : comp.lang.c
Date : 03. Apr 2025, 03:13:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vskqrh$35rt8$1@dont-email.me>
References : 1 2
User-Agent : Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2)
On Wed, 02 Apr 2025 17:36:22 -0700, Tim Rentsch wrote:

Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
 
I cannot find any definitive statement in my copies of the various
C language standards that addresses the behaviour of the C string
functions when given a NULL pointer.
>
Specifically, what does the C standard dictate about the behaviour of
  strrchr(NULL,'/')
but the question could apply to any of the string functions
(strlen(NULL), etc.)
>
My gut impression is that
  strrchr(NULL,'/'), etc
invoke undefined behaviour, and should be avoided.
>
Can anyone comment?
 
There's a general principle when reading the C standard, which
is, when looking at some leaf section, go up the tree and read
the parent section, and also read the grandparent section, and so
on.
[snip]
Incidentally, I learned this principle myself from another helpful
poster (I don't remember who) in comp.lang.c, and am happy to pass
along what has been for me helpful advice.

Many thanks, Tim

I appreciate both yours and Kaz's guidance in this.
I knew that the standard included a caveat here, but, for the life
of me, I couldn't locate it.

I appreciate the assistance; it gives me some measure of confidence
for the changes that I must make to the code that I am revising at
the moment.

Thanks again
--
Lew Pitcher
"In Skills We Trust"

Date Sujet#  Auteur
2 Apr 25 * A question regarding C string functions8Lew Pitcher
2 Apr 25 +* Re: A question regarding C string functions3Kaz Kylheku
2 Apr 25 i+- Re: A question regarding C string functions1Lew Pitcher
3 Apr 25 i`- Re: A question regarding C string functions1David Brown
3 Apr 25 +* Re: A question regarding C string functions3Tim Rentsch
3 Apr 25 i+- Re: A question regarding C string functions1Lew Pitcher
3 Apr 25 i`- Re: A question regarding C string functions1Ethan Carter
3 Apr 25 `- Re: A question regarding C string functions1James Kuyper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal