Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

  1. /***
  2. *strchr.c - search a string for a given character
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines strchr() - search a string for a character
  8. *
  9. *Revision History:
  10. * 05-31-89 JCR C version created.
  11. * 02-27-90 GJF Fixed calling type, #include <cruntime.h>, fixed
  12. * copyright.
  13. * 08-14-90 SBM Compiles cleanly with -W3, removed now redundant
  14. * #include <stddef.h>
  15. * 10-01-90 GJF New-style function declarator.
  16. * 09-01-93 GJF Replaced _CALLTYPE1 with __cdecl.
  17. *
  18. *******************************************************************************/
  19. #include <cruntime.h>
  20. #include <string.h>
  21. /***
  22. *char *strchr(string, c) - search a string for a character
  23. *
  24. *Purpose:
  25. * Searches a string for a given character, which may be the
  26. * null character '\0'.
  27. *
  28. *Entry:
  29. * char *string - string to search in
  30. * char c - character to search for
  31. *
  32. *Exit:
  33. * returns pointer to the first occurence of c in string
  34. * returns NULL if c does not occur in string
  35. *
  36. *Exceptions:
  37. *
  38. *******************************************************************************/
  39. char * __cdecl strchr (
  40. const char * string,
  41. int ch
  42. )
  43. {
  44. while (*string && *string != (char)ch)
  45. string++;
  46. if (*string == (char)ch)
  47. return((char *)string);
  48. return(NULL);
  49. }