home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / strchr.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  1KB  |  45 lines

  1. /***
  2. *strchr.c - search a string for a given character
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines strchr() - search a string for a character
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <string.h>
  13.  
  14. /***
  15. *char *strchr(string, c) - search a string for a character
  16. *
  17. *Purpose:
  18. *       Searches a string for a given character, which may be the
  19. *       null character '\0'.
  20. *
  21. *Entry:
  22. *       char *string - string to search in
  23. *       char c - character to search for
  24. *
  25. *Exit:
  26. *       returns pointer to the first occurence of c in string
  27. *       returns NULL if c does not occur in string
  28. *
  29. *Exceptions:
  30. *
  31. *******************************************************************************/
  32.  
  33. char * __cdecl strchr (
  34.         const char * string,
  35.         int ch
  36.         )
  37. {
  38.         while (*string && *string != (char)ch)
  39.                 string++;
  40.  
  41.         if (*string == (char)ch)
  42.                 return((char *)string);
  43.         return(NULL);
  44. }
  45.