home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 216.lha / EdLib_v1.0 / strrpos.c < prev    next >
C/C++ Source or Header  |  1996-02-15  |  479b  |  23 lines

  1. /* edlib  version 1.0 of 04/08/88 */
  2. /*
  3.     strrpos searches the null-terminated string string for the last
  4.     occurance of the character "key". It returns either the position
  5.     or -1 if it is not found.
  6. */
  7.  
  8. int strrpos(string,key)
  9. char *string;
  10. char key;
  11. {
  12.     char *temp;
  13.  
  14.     if ( !key )
  15.         return(strlen(string));
  16.  
  17.     for (temp = string + strlen(string) - 1; temp >= string ; temp-- )
  18.         if ( *temp == key)
  19.             return(temp - string);
  20.  
  21.     return(-1);
  22. }
  23.