result of strstr(cs,ct) when ct is a null string

Todd Karakashian todd at cfa.harvard.edu
Tue May 21 06:23:14 AEST 1991


>From article <1991May20.163227.7166 at cfa.harvard.edu>, by todd at cfa.harvard.edu (Todd Karakashian):
> 
> Is the result of strstr(cs,ct) defined when ct is a null string 
> (i.e., when *ct == '\0')?  
> 
> SunOS 4.1.1 strstr() returns cs in this situation.  I checked the man
> page, K&R 2, and the ANSI standard but couldn't find any illuminating
> information (like, for example, saying it was undefined).
> 
> I am thinking perhaps that strstr() ought to return NULL in this case, or
> maybe a pointer to the null termination of cs, but I am curious what
> other people think.  
> 
> Thanks...
> 
> 				Todd
> 

Well!  Having now perused the ANSI standard more carefully, I find in
4.11.5.7:

	"if s2 points to a string of zero length, the function
returns s1."

Whoops - very sorry to bother you.  In the words of Emily Latella:

			"Never mind."


-- 
########################################################################
## Todd Karakashian		          todd at cfa.harvard.edu (I-net)##
## Smithsonian Astrophysical Observatory  ...harvard!cfa!todd (uucp)  ##
## 60 Garden Street, MS 70		  todd at cfa (BITNET)           ##



More information about the Comp.lang.c mailing list