home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / JPLC2.ZIP / STRNCMP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-22  |  734 b   |  24 lines

  1. /* 1.1  02-10-86                        (strncmp.c)
  2.  ************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1984, 86    *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10.  
  11. /************************************************************************/
  12.  
  13. strncmp(s, t, n)    /* compares s and t for max of n chars. Returns
  14.                0 if equal, a neg. no. if s<t, pos. if s>t    */
  15. /*----------------------------------------------------------------------*/
  16. STRING s, t;
  17. int n;
  18. {
  19.     for ( ; --n > 0 AND *s IS *t; s++, t++)
  20.         if (*s IS NULL)
  21.             return (0);
  22.     return (*s - *t);
  23. }
  24.