home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff218.lzh / EdLib / strrpos.c < prev    next >
Text File  |  1989-06-04  |  641b  |  28 lines

  1. /*
  2.  * edlib v1.1 Copyright 1989 Edwin Hoogerbeets
  3.  * This code is freely redistributable as long as no charge other than
  4.  * reasonable copying fees are levied for it.
  5.  */
  6.  
  7. /*
  8.     strrpos searches the null-terminated string string for the last
  9.     occurance of the character "key". It returns either the position
  10.     or -1 if it is not found.
  11. */
  12.  
  13. int strrpos(string,key)
  14. register char *string;
  15. register char key;
  16. {
  17.     register char *temp;
  18.  
  19.     if ( !key )
  20.         return(strlen(string));
  21.  
  22.     for (temp = string + strlen(string) - 1; temp >= string ; temp-- )
  23.         if ( *temp == key)
  24.             return(temp - string);
  25.  
  26.     return(-1);
  27. }
  28.