home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / dlibssrc / strrpos.c < prev    next >
Encoding:
Text File  |  1987-06-14  |  379 b   |  21 lines

  1. int strrpos(string, symbol)
  2. register char *string;
  3. register char symbol;
  4. /*
  5.  *    Return the index of the last occurance of <symbol> in <string>.
  6.  *    -1 is returned if <symbol> is not found.
  7.  */
  8. {
  9.     register int i = 0;
  10.     register char *p = string;
  11.  
  12.     while(*string++)
  13.         ++i;
  14.     do {
  15.         if(*--string == symbol)
  16.             return(i);
  17.         --i;
  18.     } while(string != p);
  19.     return(-1);
  20. }
  21.