home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / strings / c_string / strsuff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-04-09  |  816 b   |  29 lines

  1.  
  2. /*f File   : strsuff.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 11 April 1984
  5.     Defines: strsuff()
  6.  
  7.     strsuff(src, suffix)
  8.     checks whether suffix is a suffix of src.  If it is not, the  result
  9.     is NullS.  If it is, the result is a pointer to the character of src
  10.     where suffix starts (which is the same as src+strlen(src)-strlen(prefix) ).
  11.     See strpref.c for a comment about using if (strsuff(...)) in C.
  12. */
  13.  
  14. #include "strings.h"
  15.  
  16. char *strsuff(src, suffix)
  17.     register char *src, *suffix;
  18.     {
  19.         register int L; /* length of suffix */
  20.  
  21.         for (L = 0; *suffix++; L++)
  22.             if (!*src++) return NullS;
  23.         while (*src++) ;
  24.         for (--src, --suffix; --L >= 0; )
  25.             if (*--src != *--suffix) return NullS;
  26.         return src;
  27.     }
  28.  
  29.