index and rindex question...

Chris Torek chris at mimsy.umd.edu
Fri Feb 2 11:45:11 AEST 1990


In article <11716.25C6818B at urchin.fidonet.org>
Bob.Stout at p6.f506.n106.z1.fidonet.org (Bob Stout) writes:
>  Both the strchr() and strrchr() functions made it into the ANSI spec while  
>index() and rindex() didn't. I believe this was because the latter two  
>functions on some systems return an int offset of the character rather
>than a pointer to it.

Unless there are some *extremely* broken systems out there (this is
always a possibility), there are no systems on which index() and rindex()
return an int.

index and rindex, wherever present, should be EXACTLY identical to
strchr and strrchr, so that, e.g.,

	#define index strchr
	#define strrchr rindex

should work (if you have both in your C library).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list