home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / Chip_2002-02_cd1.bin / sharewar / apaths / APSOURCE.ZIP / lstrrchr.c < prev    next >
C/C++ Source or Header  |  2001-03-26  |  941b  |  35 lines

  1. /* lstrrchr - March 26th, 2001
  2. **
  3. **      Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
  4. **
  5. **      This function scans a string for the last occurrence of a character.
  6. **
  7. **      Called:     string = a pointer to the string to search.
  8. **                  c      = the character to scan for.
  9. **
  10. **      Returns:    A pointer to the last occurrence of c in string,
  11. **                  or NULL if c is not found.
  12. **
  13. **      Notes:      This function is provided to eliminate the need for
  14. **                  linking in the the Standard C Library.
  15. */
  16.  
  17. #include "AppPaths.h"
  18.  
  19. extern LPSTR far lstrrchr (LPSTR string,int c)
  20. {
  21.     auto int    len = lstrlen (string);
  22.     auto int    i;
  23.  
  24.     if (!len) return (NULL);
  25.  
  26.     for (i = len - 1; i >= NIL; i--)
  27.  
  28.         if (string[i] == (char) c)
  29.             return (&string[i]);
  30.  
  31.     return (NULL);
  32. }
  33.  
  34. /* end of lstrrchr.c - written by Gregory Braun */
  35.