home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / string.arc / STRPREF.C < prev    next >
Text File  |  1984-12-31  |  1KB  |  26 lines

  1. /*  File   : strpref.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 11 April 1984
  4.     Defines: strpref()
  5.  
  6.     strpref(src, prefix)
  7.     checks whether prefix is a prefix of src.  If it is not, the  result
  8.     is  NullS.  If it is, the result is a pointer to the first character
  9.     of src after the prefix (src+strlen(prefix)).  You can use this in a
  10.     conditional as a test: if (strpref(....)), but this is only portable
  11.     provided you remember to declare strpref() properly or use strings.h
  12.     as if (...) tests numbers against 0 and pointers against a suitable
  13.     cast of 0; there is no guarantee that (char*)0 is represented by the
  14.     same bit pattern as (int)0.
  15. */
  16.  
  17. #include "strings.h"
  18.  
  19. char *strpref(src, prefix)
  20.     register char *src, *prefix;
  21.     {
  22.     while (*prefix) if (*src++ != *prefix++) return NullS;
  23.     return src;
  24.     }
  25.