Back to index

cell-binutils  2.17cvs20070401
strchr.c
Go to the documentation of this file.
00001 /* Portable version of strchr()
00002    This function is in the public domain.  */
00003 
00004 /*
00005 
00006 @deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
00007 
00008 Returns a pointer to the first occurrence of the character @var{c} in
00009 the string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
00010 null character, the results are undefined.
00011 
00012 @end deftypefn
00013 
00014 */
00015 
00016 #include <ansidecl.h>
00017 
00018 char *
00019 strchr (register const char *s, int c)
00020 {
00021   do {
00022     if (*s == c)
00023       {
00024        return (char*)s;
00025       }
00026   } while (*s++);
00027   return (0);
00028 }