home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / strchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1.0 KB  |  66 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strchr.c,v 1.1 1996/12/11 11:18:27 aros Exp $
  4.  
  5.     Desc: ANSI C function strchr()
  6.     Lang: english
  7. */
  8. #include <stdio.h>
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <string.h>
  14.  
  15.     char * strchr (
  16.  
  17. /*  SYNOPSIS */
  18.     const char * str,
  19.     int         c)
  20.  
  21. /*  FUNCTION
  22.     Searches for a character in a string.
  23.  
  24.     INPUTS
  25.     str - Search this string
  26.     c - Look for this character
  27.  
  28.     RESULT
  29.     A pointer to the first occurence of c in str or NULL if c is not
  30.     found in str.
  31.  
  32.     NOTES
  33.  
  34.     EXAMPLE
  35.     char buffer[64];
  36.  
  37.     strcpy (buffer, "Hello ");
  38.  
  39.     // This returns a pointer to the first l in buffer.
  40.     strchr (buffer, 'l');
  41.  
  42.     // This returns NULL
  43.     strchr (buffer, 'x');
  44.  
  45.     BUGS
  46.  
  47.     SEE ALSO
  48.     strrchr()
  49.  
  50.     INTERNALS
  51.  
  52.     HISTORY
  53.  
  54. ******************************************************************************/
  55. {
  56.     while (*str)
  57.     {
  58.     if (*str == c)
  59.         return ((char *)str);
  60.  
  61.     str ++;
  62.     }
  63.  
  64.     return NULL;
  65. } /* strchr */
  66.